feat: support incremental build when composite is true #416
+360
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Our current logic using the Typescript compiler API is:
build mode
dts.build: false
: basic compiler withcreateCompilerHost
andcreateProgram
dts.build: true
: incremental build with project references, usingcreateSolutionBuilderHost
andcreateSolutionBuilder
watch mode
dts.build: false
: incremental program watcher withcreateWatchCompilerHost
andcreateWatchProgram
dts.build: true
: incremental build with project references, usingcreateSolutionBuilderWithWatchHost
andcreateSolutionBuilderWithWatch
In this PR, we add
createIncrementalCompilerHost
andcreateIncrementalProgram
in build mode to support incremental and deal with projects that withcomposite: true
(incremental: true
) and do not to build references dependencies. The watch mode API originally support incremental, so we do not to deal with it in this scenerio.Our logic is beyond what fork-ts-checker-webpack-plugin do
https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/0fab463b21c6edc4d94834568a3f440241d57887/src/typescript/worker/get-issues-worker.ts#L66-L73
For compiler API that not use
SolutionBuilder
, it seems the buildinfo not actually takes effect, it just generate buildinfo files. And for tsbuildinfo, due to various issues caused by buildinfo such as remove distPath and monorepo sceniro, we decide to delete buildinfo before generating dts in the next PR which is aligned with Modern.js Module. And our dts processing behaviour such as redirect alias, modify dts extensions and adding banner/footer are also not compatitle with ts cache.For users who want to keep most align with the default behaviour with
tsc
in incremetal scenerio, they can enabledts.build: true
but I think there's no need to do this if they do not want to build dependencies.Hopefully there won’t be a day where we switch to using tsc bin files directly, and the ts compiler api will be easier to use with more extensive documentation and able to align related behaviors with tsc more easily.
Related Links
close: #404
Checklist