perf(@angular/build): optimize incremental watch rebuilds in AOT compilation - #34173
alan-agius4 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes incremental builds in the Angular compilation pipeline by caching the tsconfig configuration and managing the internal state of the TypeScript BuilderProgram to prevent false-positive .d.ts cascades during watch rebuilds. It also refactors file reference collection to be more efficient. The feedback highlights a critical issue where the newly added builder program synchronization and state-committing logic is placed at the end of a generator function. Since generator execution can terminate early, this logic should be wrapped in a try...finally block to guarantee it runs.
There was a problem hiding this comment.
Code Review
This pull request optimizes incremental builds in the Angular compilation pipeline by caching the parsed TypeScript configuration and introducing state synchronization to prevent false-positive .d.ts cascades. It also refactors resource dependency handling during file reference collection. The review feedback suggests making the .json file extension check case-insensitive to ensure robust cache invalidation across different filesystems.
ad232b6 to
c3b5d77
Compare
This comment was marked as outdated.
This comment was marked as outdated.
0912b99 to
f23c21c
Compare
f23c21c to
357186d
Compare
…ilation - Pre-populate `.d.ts` shape signatures on the previous `BuilderProgram` for modified files prior to diffing when type-checking or TypeScript transpilation is active, preventing false-positive `.d.ts` cascades on incremental watch edits. - Synchronize `typeScriptProgram` with `angularCompiler.getCurrentProgram()` after `collectDiagnostics()` and clear uncommitted `changedFilesSet` and `oldSignatures` entries so subsequent incremental builds preserve `.d.ts` signatures and do not treat `.ngtypecheck.ts` shims as newly added files. - Detect affected dependent `.ngtypecheck.ts` shims in `isolatedModules` / `verbatimModuleSyntax` mode via TypeScript's `state.hasCalledUpdateShapeSignature`, ensuring cross-component template diagnostics are re-evaluated when a dependency's `.d.ts` shape changes without cascading on private edits. - Avoid `filter().flatMap()` allocations and skip `getResourceDependencies()` for declaration files when collecting `referencedFiles`.
357186d to
8e343ea
Compare
Optimizes incremental watch rebuilds in
AotCompilation:.d.tsshape signatures on the previousBuilderProgramfor modified files prior to diffing when type-checking or TypeScript transpilation is active, preventing false-positive.d.tscascades on incremental watch edits.typeScriptProgramwith Angular's template type-checking program (angularCompiler.getCurrentProgram()) aftercollectDiagnostics()and clear uncommittedchangedFilesSetandoldSignaturesentries so subsequent incremental builds preserve.d.tssignatures and do not treat.ngtypecheck.tsshims as newly added files..ngtypecheck.tsshims inisolatedModules/verbatimModuleSyntaxmode via TypeScript'sstate.hasCalledUpdateShapeSignature, ensuring cross-component template diagnostics are re-evaluated when a dependency's.d.tsshape changes without cascading on private edits.filter().flatMap()allocations and skipgetResourceDependencies()for declaration files when collectingreferencedFiles.Tip
Consider enabling Hide whitespace (view with
?w=1) when reviewing this PR for a cleaner diff.