-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
[FR]: Better documentation for tsconfig #740
Comments
I think we are just missing one sentence explaining when+how to extend that root tsconfig. I don't understand the issue with libraries used in both node and nextjs. How is that relevant to tsconfig? |
Yes, that would be great! :)
Well, each So if I have a
I don't know which tsconfig to use in |
So you're compiling the same .ts files multiple times with different configs? Ideally you wouldn't have to do that at all... compile once to a format that can be used by a bundler and node. Otherwise it's a mess that requires re-compiling the same files multiple times to multiple output locations etc :/ |
But how would I do this? The Example:
with the root tsconfig being something like
Maybe it's something I am not understanding, but how do people normally deal with this? Thanks a lot for your answers anyway! That's very much appreciated :) |
I've actually never used the |
Do you have an example tsconfig I could take a look at? Part of the problem is imports (which is how I arrived at this issue in the first place). When running as a node binary, you should import the library as follows:
Note the When running in nextJS, the opposite is true - one should use
in order to find it correctly. See https://www.typescriptlang.org/tsconfig/#moduleResolution, specifically "but unlike the Node.js resolution modes, bundler never requires file extensions on relative paths in imports." So my current situation is:
So I am wondering what are the solutions that other people employ in their monorepo. Maybe there's a simple solution to this that I am completely missing :/ |
I've always seen the opposite lol - bundlers normally don't care about the file extension and can figure it out. It's not runtime so it's not super import if it's Don't the typescript docs confirm exactly that? When it says "but unlike the Node.js resolution modes, bundler never requires file extensions on relative paths in imports." I interpret that as a bundler not caring about extensions on relative paths but runtime might. So if you need to be compatible with both you'd use extensions? |
What is the current behavior?
Hi,
the current documentation for tsconfig (https://github.com/aspect-build/rules_ts/blob/main/docs/tsconfig.md) it's a bit unclear. It is recommended to use a single tsconfig file at the root of the repository and use it for every ts_project target, but it doesn't explain how to deal with different target types.
Tsconfig has some options (e.g.
moduleResolution
,module
) which depend on the type of output we're building (a node binary requires different options vs a nextJS server). So it's unclear how a single tsconfig can work for both.Even if one can extend the ts_project when needed (e.g. overwrite the relevant tsconfig options in the nextJS target), it's unclear how one would deal with base libraries which are used both in a node binary and a nextJS server. What should their tsconfig be set to, if it should apply to both cases?
Describe the feature
Would be great if this could be clarified and what is the expected way to structure the ts_project / ts_config targets in these cases.
Ideally a library is just a library (like py_library) and doesn't require potentially incompatible options to be set based on where it will be used downstream
The text was updated successfully, but these errors were encountered: