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

doesn't support jsconfig.json #2

Open
Glenn-Sharecare opened this issue Oct 7, 2022 · 3 comments
Open

doesn't support jsconfig.json #2

Glenn-Sharecare opened this issue Oct 7, 2022 · 3 comments

Comments

@Glenn-Sharecare
Copy link

It would be a really easy change to support this as well. same format, different name

@yakovlev-alexey
Copy link
Owner

Hi, @Glenn-Sharecare! Pretty sure jsconfig.json is used purely for your IDE IntelliSense. According to docs at https://code.visualstudio.com/docs/languages/jsconfig it is needed when your project has complex path aliasing that VSCode integrated Javascript language server can't parse.

In my opinion it should not be used to configure how the project is built. I am not totally against having a single file that configures how path aliases for vanilla Javascript projects. But I am certain that it should not be in the same project/package as the TypeScript resolver since it would blur out the responsibility of this package. Be free to fork this project and create a version for jsconfig.json.

@Glenn-Sharecare
Copy link
Author

jsconfig is just a js specific version of tsconfig, which is supported in this library. Here is the typescript page on tsconfig that also covers jsconfig (briefly). https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

It is true that VS code supports it, which is nice. Not having to repeat yourself and try to maintain two lists of aliases is pretty swell. In fact it'd be really cool if webpack supported it as well.

@yakovlev-alexey
Copy link
Owner

From the brief description that Typescript docs have on it I see jsconfig.json described as just a common alias to tsconfig.json for certain projects with no specifics on what some JavaScript-related compiler flags enabled by default are. I think this issue raises a larger question on how to enable tsconfig aliasing in this plugin.

Currently it seems like Parcel would not allow its plugins to access any command line arguments (or implement additional ones). I can see 2 options here and both seems like quite poor hacks:

  1. Use an environment variable like PARCEL_TSCONFIG_PATH or something like that to get the path you want
  2. Use a separate file with a constant name like .parceltsrc

The second option is very dirty and kind of defeats the purpose. Still both options suffer from a giant issue - even if this resolver is able to read Typescript configuration from a different file Parcel can't! From what I found in Parcel source code it always looks for tsconfig.json file starting from the file and going up the directory structure until it reaches the project root.

https://github.com/parcel-bundler/parcel/blob/a171677e90829b4733397160ad177890cb6f2cee/packages/utils/ts-utils/src/loadTSConfig.js#L12

In conclusion, I do not think it makes sense to teach this plugin reading different tsconfig names since Parcel itself does not support that. If I have the time I will open an issue in Parcel (if one does not already exists). You may do it yourself and reference this issue there and I will participate in the conversation. If and when Parcel implements tsconfig file aliasing it will get implemented here as well.

BTW looking at Parcel sources I found out that it resolves tsconfig not only at the root but it looks recursively from file path to project root. Will look at this issue in #3

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

2 participants