Repository navigation
perf(@angular/build): cache pre-declaration transformed SourceFiles during AoT emit - #34425
Conversation
…uring AoT emit Cache transformed `SourceFile` ASTs in a `Map` in `ensurePreDeclarationTransformers` instead of only tracking visited files in a `Set`. When `.d.ts`-only emit runs prior to `.js` emit (such as for transitive importers during incremental library builds), the subsequent `.js` emit now reuses the cached transformed `SourceFile` instead of executing `before` transformers a second time.
…Files during AoT emit
There was a problem hiding this comment.
Code Review
This pull request exports and refactors the ensurePreDeclarationTransformers function in aot-compilation.ts to properly cache and reuse pre-transformed source files. The implementation now combines all before-transformers into a single transformer and utilizes a map to cache the transformed ASTs during the declaration emit phase, preventing redundant executions when subsequently emitting JavaScript. Comprehensive unit tests have also been added in angular-compilation_spec.ts to verify this behavior. There are no review comments, so I have no feedback to provide.
…Files during AoT emit
|
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. |
Summary
BuilderProgram.emitNextAffectedFileemits.d.ts-only (emitOnly = Dts) for an affected transitive importer, TypeScript skipstransformers.beforeand runstransformers.afterDeclarations.ensurePreDeclarationTransformersrunsbeforetransformers insideafterDeclarationsto populate Angular'sdtsTransforms, and caches the transformedts.SourceFileinpreTransformedSourceFilesonly for those.d.ts-first files (deleting the entry immediately when consumed by a subsequent.jsemit)..js-first / combined.js+.d.tsemits, tracksseenSourceFilesvia aSet<ts.SourceFile>without retaining transformedSourceFileASTs in memory across the emit loop.Benchmark Results
main