You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TS build output not invalidated when node_modules changed #38648
Changes to types within node_modules do not invalidate the TypeScript build output.
Suppose we have a project with project references enabled and that there are no TypeScript errors in the project. If we update our node_modules to a new version of a package that contains types, that could introduce errors into our project. However, if we leave the build output directory in place, we do not see these errors in the tsc -b output.
tsc -b -- no errors.
Update types within node_modules that should trigger error.
tsc -b -- no errors, which is unexpected.
Upon inspection of the tsbuildinfo files, the shas for the node_modules d.ts files do not get updated.
We cache our TS output directory between CI builds so that we can incrementally build from it on subsequent builds. We currently invalidate our cache whenever node_modules changes. Ideally, we could keep the cache and TypeScript could figure out what needs to be recompiled.
Separately, it would be great if the validity rules for the TypeScript output were documented as part of the project references docs. That would help us better understand when it is safe to rebuild from an existing output vs requiring a clean build (between TS versions, when node_modules change, etc).
During an incremental rebuild, declaration files that aren't immediately included in the compilation process (i.e. those in node_modules, unless you specifically included them) aren't checked for up-to-dateness because figuring out which of those files are in the program in the first place is a major performance burden.
A few options:
Run -tsc -b -f to force a rebuild when you know these files have changed
Modify your include or files list to include node_modules/**/*.d.ts (warning: This will slow down all your incremental builds)
Got it. So sounds like ignoring the previous output directory (either by not restoring it or tsc -b -f) is the best we can do in this case. Wouldn't want to slow down all incremental builds.
What are the other output/cache invalidation conditions when we should use -f?
So far it sounds like:
When node_modules change
Anything else?
Would have maybe thought "When TypeScript version changes" but looks like the output tsbuildinfo files contain the version number.
I think that's it, unless you have other places where .d.ts files might get read in from outside of node_modules (this is unlikely in my estimation, but it's possible).
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
Activity
RyanCavanaugh commentedon Jun 8, 2020
During an incremental rebuild, declaration files that aren't immediately included in the compilation process (i.e. those in
node_modules, unless you specifically included them) aren't checked for up-to-dateness because figuring out which of those files are in the program in the first place is a major performance burden.A few options:
-tsc -b -fto force a rebuild when you know these files have changedincludeorfileslist to includenode_modules/**/*.d.ts(warning: This will slow down all your incremental builds)brieb commentedon Jun 11, 2020
Got it. So sounds like ignoring the previous output directory (either by not restoring it or
tsc -b -f) is the best we can do in this case. Wouldn't want to slow down all incremental builds.What are the other output/cache invalidation conditions when we should use
-f?So far it sounds like:
Anything else?
Would have maybe thought "When TypeScript version changes" but looks like the output tsbuildinfo files contain the version number.
RyanCavanaugh commentedon Jun 11, 2020
I think that's it, unless you have other places where
.d.tsfiles might get read in from outside ofnode_modules(this is unlikely in my estimation, but it's possible).typescript-bot commentedon Jun 16, 2020
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.