Open jgbright opened 2 years ago
Hi, is there any update on this one, since I am also running into the same problem. The difference in my case is, that I am using an angular application and an angular library. However, the setup is the same as in the provided demo repository. Meaning, that I have different incompatible TypeScript settings between the angular application and the library.
So, is this also a wrong assumption on my side, or is the expected way to refer to the dist
folder of the library inside the tsconfig.base.json
?
I have the same problem on my side. I want to move an old library which is not in strict mode yet to an app which has strict mode enabled. In the library tsconfig.json
I have disabled strict mode, but when building the app the library tsconfig.json
settings are ignored.
I also have the same problem in nx 15.4.2 with typescript 4.9. Turning on noUncheckedIndexedAccess
in app will also apply to lib when building app
same problem. we can not activate the strict mode for new apps if they have to use the older libraries without enabled strict mode.
I also have this issue when trying to use strict mode for newer apps! 😕
I have similar issue with nx 16.0.1. My shared lib feature generated with @nx/js:lib has strict mode set to true in the tsconfig.json but it is not honoured by the consumer express app generated with @nx/express until I either set the "strictNullChecks": true
or the "strict":true
in the tsconfig.json for the express app.
Does anyone know if there is a document explaining the various tsconfig files used by the apps, libs?
same problem. would appreciate any possible solutions
This has always confused me.
We're not using buildable libs. We have a few apps (each with a tsconfig), and a load of libs (all with their own tsconfig).
When we build an app, it builds everything using the tsconfig from the app (as its the app being built and you can only use one tsconfig!)
We've recently made a few of the libs strict:true
so we can improve code over time. Our IDE picks this up during development, but any errors won't fail the build (as the build is running with the application's tsconfig which is strict:false).
It's clear from chatting to the team that this isn't understood well. Many people thought that the library's tsconfig.json would be used during build (although it does make sense that it isn't...)
Further, we recently trialled adding Cypress Component Testing and it seems it's building the lib using the app as a devServerTarget, but with the library's tsconfig (why?). This means that if the lib imports from any other lib with a strict:true config, it'll fail the CCT build, despite the application build still passing.
Not sure how this changes if we make the library buildable...
Why does NX include a separate tsconfig for every library (especially non-buildable ones)?
We could use some better documentation around this stuff I think.
Ran into this problem today, still occurring 10/2023.
This has always confused me.
We're not using buildable libs. We have a few apps (each with a tsconfig), and a load of libs (all with their own tsconfig).
When we build an app, it builds everything using the tsconfig from the app (as its the app being built and you can only use one tsconfig!)
We've recently made a few of the libs
strict:true
so we can improve code over time. Our IDE picks this up during development, but any errors won't fail the build (as the build is running with the application's tsconfig which is strict:false).It's clear from chatting to the team that this isn't understood well. Many people thought that the library's tsconfig.json would be used during build (although it does make sense that it isn't...)
Further, we recently trialled adding Cypress Component Testing and it seems it's building the lib using the app as a devServerTarget, but with the library's tsconfig (why?). This means that if the lib imports from any other lib with a strict:true config, it'll fail the CCT build, despite the application build still passing.
Not sure how this changes if we make the library buildable...
Why does NX include a separate tsconfig for every library (especially non-buildable ones)?
We could use some better documentation around this stuff I think.
I think we could use ANY documentation around this. This is such a shame this things are found out this way :(
I also have this problem today... 12/2023
I believe there's still no solution or workaround available. 2/2024
I understood here https://nx.dev/recipes/angular/setup-incremental-builds-angular#adjust-the-application-executor, that we need to set options.buildLibsFromSource: false
in the app config.
I understood here https://nx.dev/recipes/angular/setup-incremental-builds-angular#adjust-the-application-executor, that we need to set
options.buildLibsFromSource: false
in the app config.
Thanks for sharing. This flag solved it in our project.
Current Behavior
If you generate an nx workspace with an app and a lib with different tsconfig options, the lib's ts options will differ when built individually vs when it is built as part of the app. When the lib is built, it uses the tsconfig settings from the lib. When the app is built, the app and the lib are built using the tsconfig settings from the app. This is problematic when the app and lib need different tsconfig options.
I also observe this unexpected behavior when running the web:dev-server executor. That could be due to the same root cause.
Expected Behavior
I expected the lib's tsconfig to be used by the lib both when it is built separately and when it is built as part of the app.
I believe this is either an incorrect assumption on my part or a gap in what the generator produces. I assume that because the generated app and lib each have their own tsconfig files, that they could be configured separately and still work together.
I don't know if this a regression.
Steps to Reproduce
See minimal repro repo here: https://github.com/jgbright/nx-multiple-ts-configs
Failure Logs
Transcripts of running various nx commands available here: https://github.com/jgbright/nx-multiple-ts-configs/blob/main/README.md
Environment