Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild does not properly resolve extends field in tsconfig.json #279

Closed
haggholm opened this issue Jul 20, 2020 · 4 comments
Closed

esbuild does not properly resolve extends field in tsconfig.json #279

haggholm opened this issue Jul 20, 2020 · 4 comments

Comments

@haggholm
Copy link

If the tsconfig.json file contains an extends field, and this field is a package reference rather than pointing specifically to the JSON file, it is not properly resolved by esbuild.

For example, I may have a package @my-scope/tsconfig-base, where package.json specifies its main entry as tsconfig.json. Then this will work:

{ "extends": "@my-scope/tsconfig-base/tsconfig.json" }

but this will not:

{ "extends": "@my-scope/tsconfig-base" }

The Typescript documentation specifies that “The path may use Node.js style resolution”; I interpret this as meaning that it should resolve main entries in referenced packages.

@evanw
Copy link
Owner

evanw commented Jul 25, 2020

This doesn't appear to be how the official TypeScript compiler works. Here's what I did to test it:

  • entry.tsx

    console.log(<div/>)
  • tsconfig.json

    { "extends": "@my-scope/tsconfig-base" }
  • node_modules/@my-scope/tsconfig-base/package.json

    { "main": "./test.json" }
  • node_modules/@my-scope/tsconfig-base/test.json

    { "compilerOptions": { "jsx": "react", "jsxFactory": "worked" } }

Trying to build this with the official TypeScript compiler using tsc --project . gives the error File '@my-scope/tsconfig-base' not found. It appears to me that the official TypeScript compiler does not respect the main field of package.json when resolving the extends path of tsconfig.json.

@haggholm
Copy link
Author

Embarrassing. Nonetheless, I have packages that build with the official TS compiler, but not with esbuild—I guess at this rate I don’t really know whether to regard this as being by specification or as a side effect. My scoped config packages have their main entry set to tsconfig.json, and (hence) each has a tsconfig.json file in the package root directory: I guess the official compiler defaults to looking for the file by name rather than by looking at package.json.

@evanw evanw closed this as completed in fb36385 Jul 28, 2020
@evanw
Copy link
Owner

evanw commented Jul 29, 2020

This should be fixed in version 0.6.9.

@neves
Copy link

neves commented Sep 1, 2020

Now I'm having the opposite problem:
https://gist.github.com/neves/05b17fce65cdc3c92010537a162b3c25
"extends": "@tsconfig/recommended" works!
but
"extends": "@tsconfig/recommended/tsconfig.json" doesn't.

Implemented here and broked here
the order was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants