perf(@angular/build): decouple diagnostic type checking from build start - #34043
Open
alan-agius4 wants to merge 1 commit into
Open
perf(@angular/build): decouple diagnostic type checking from build start#34043alan-agius4 wants to merge 1 commit into
alan-agius4 wants to merge 1 commit into
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.
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.
alan-agius4
force-pushed
the
perf/decouple-compiler-diagnostics
branch
from
September 8, 2026 13:25
d31ff5e to
b45232d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.