Skip to content

refactor(@angular/build): encapsulate TypeScript source file AST caching in compilation classes - #33863

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:refactor/source-file-ast-cache
Open

refactor(@angular/build): encapsulate TypeScript source file AST caching in compilation classes#33863
clydin wants to merge 1 commit into
angular:mainfrom
clydin:refactor/source-file-ast-cache

Conversation

@clydin

@clydin clydin commented Aug 14, 2026

Copy link
Copy Markdown
Member

Move the ts.SourceFile AST cache out of SourceFileCache and directly into AotCompilation and JitCompilation. This removes the Map<string, ts.SourceFile> inheritance from SourceFileCache and removes the sourceFileCache property from AngularHostOptions, further decoupling the bundler plugin and generic host interfaces from TypeScript AST structures.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 14, 2026
@clydin
clydin force-pushed the refactor/source-file-ast-cache branch from 53504a6 to 8685f2c Compare August 14, 2026 15:25
@clydin
clydin marked this pull request as ready for review August 14, 2026 15:28

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Angular compiler host and compilation classes to manage TypeScript source file caching internally rather than through the shared SourceFileCache class. Specifically, AotCompilation and JitCompilation now maintain their own #sourceFiles maps, and SourceFileCache no longer extends Map. In parallel-worker.ts, the cache is replaced with a module-level modifiedFiles set. The review feedback highlights a critical race condition in parallel-worker.ts where concurrent file updates occurring during the asynchronous initialize function could be lost when modifiedFiles.clear() is called at the end. The reviewer suggests capturing and clearing the modified files synchronously at the start of the initialization process to prevent this data loss.

Comment thread packages/angular/build/src/tools/angular/compilation/parallel-worker.ts Outdated
Comment thread packages/angular/build/src/tools/angular/compilation/parallel-worker.ts Outdated
@clydin
clydin force-pushed the refactor/source-file-ast-cache branch from 8685f2c to 940466f Compare August 14, 2026 15:34
…ing in compilation classes

Move the `ts.SourceFile` AST cache out of `SourceFileCache` and directly into `AotCompilation` and `JitCompilation`. This removes the `Map<string, ts.SourceFile>` inheritance from `SourceFileCache` and removes the `sourceFileCache` property from `AngularHostOptions`, further decoupling the bundler plugin and generic host interfaces from TypeScript AST structures.
@clydin
clydin force-pushed the refactor/source-file-ast-cache branch from 940466f to dcaa1db Compare August 14, 2026 15:48
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 14, 2026
@clydin
clydin requested a review from alan-agius4 August 14, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant