-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for multiple tsconfig.xxx.json
per app/library
#42
Comments
Hi @Papooch could you please give me a better picture how your project is setup and also how you use the tool against it. From what I read it is like that or? If not please correct it and add the execution command and/or the update-ts-reference.yml to your answer.
|
Thank you for the reply, the structure looks almost like what you show, but with the exception that each lib has one
Basically the same setup as described here: https://moonrepo.dev/docs/guides/javascript/typescript-project-refs, but with a slightly different naming conventions |
When I understand correctly the approach this build config is also used for local development which in my eyes isn't necessary I even would say this an antipattern, because it abused project references to trigger a additional build step for the same package. In your case I assume it does two for spec and build under the hood. |
The build tsconfig (sometimes called The reason two are needed is because test files generally also need the testing framework types, which are not exposed to the app. Also, in the test files, we might want to loosen the strictness of typescript to enable easier mocking. This is definitely not an exhaustive list, but separating these tsconfigs is by no means an anti pattern. However, I am not sure where you're coming from with your question/remark? |
I was reading this below and this was pointing out to add them as project references to ensure that the lib folder is created to access the types.
To just underline my reasoning (without blaming or offending) here the explanation from the docs:
By giving TS the info via references it determines what to build first and in which order. Now the example with reference two local tsconfigs and let's assume package a depends on package b and you want to build a
If you have a huge repo with a lot of packages and dependency that advantage of having an improvement on the build time might turn to the opposite in my opinion. |
I agree that it might not be the ideal solution, but there's no perfect setup for monorepos and TypeScript (this guy wrote a great sunnary). As I said, I need these references for editor support (VSCode, but I would assume it's not the only one). If the references are not there, then go to source and name refactoring doesn't work (it instead goes to the built version) I also need multiple tsconfigs per project for the reasons stated earlier. I can solve both of my problems by adding those references, maybe at the expense of a slower builds, but since I also employ incremental build ( What is also nice is that I can type-check the entire codebase at once instead of iterating over all projects and triggering the type-check for each one. Currently I need to remember to add a new reference to the I was hoping to use this tool to automate the process, but unfortunately, it fell short for out setup (which is by no means unique). The simplest solution I see would be to add a CLI flag that prevents removing existing references ( Is this something you'd consider adding? |
I have a monorepo setup (
pnpm workspaces
), where each package has essentially three tsconfigstsconfig.build.json
- for the build optionstsconfig.spec.json
- for test-specific options (e.g. including test files)tsconfig.json
- which ties them together via references with the content:Where
tsconfig.base.json
is the very root one.When I run this script in the project, it removes those references completely, leaving me with this:
which I don't want, because it breaks editor support.
I just want it to add references to libraries that this one depends on. Is there any way of achieving that?
The text was updated successfully, but these errors were encountered: