Repository navigation
perf(@angular/build): decouple diagnostic type checking from build start - #34043
Conversation
There was a problem hiding this comment.
Code Review
This pull request defers the resolution of Angular compilation diagnostics by storing the diagnosticsPromise during the start phase and awaiting it asynchronously inside the build.onEnd callback. Feedback on these changes highlights two issues: first, a potential unhandledRejection in Node.js if compilation.diagnoseFiles rejects before onEnd is called, which can be mitigated by attaching a .catch() handler immediately; second, in watch mode, hasCompilationErrors is not reset to true at the start of a rebuild, which can incorrectly signal to other compilations that there are no errors if a rebuild fails early.
d31ff5e to
b45232d
Compare
Previously, the compiler plugin sequentially awaited compilation.diagnoseFiles() in build.onStart before returning to esbuild. Because build.onStart blocked until TypeScript diagnostic checks finished, esbuild's Go bundler sat idle while single-threaded type checking occurred, preventing module resolution and bundling from running concurrently. To overlap bundling with type checking: - Initiate compilation.diagnoseFiles() asynchronously during build.onStart without awaiting its completion. - Allow build.onStart to return immediately once compilation emit is complete, enabling esbuild to begin bundling and file resolution concurrently. - Await the diagnostics promise in build.onEnd, merging any diagnostic errors or warnings into the final build result. In benchmarks on clean builds, this overlaps diagnostic checks with bundling, saving ~150 ms in small projects and 500 ms to 2,000+ ms in large enterprise codebases.
488c387 to
3267c57
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously, the compiler plugin sequentially awaited compilation.diagnoseFiles() in build.onStart before returning to esbuild.
Because build.onStart blocked until TypeScript diagnostic checks finished, esbuild's Go bundler sat idle while single-threaded type checking occurred, preventing module resolution and bundling from running concurrently.
To overlap bundling with type checking:
In benchmarks on clean builds, this overlaps diagnostic checks with bundling, saving ~150 ms in small projects and 500 ms to 2,000+ ms in large enterprise codebases.