Repository navigation
perf(@angular/build): avoid TS AST eviction and d.ts re-emit on external resource edits - #34433
Merged
alan-agius4 merged 1 commit intoOct 21, 2026
Conversation
alan-agius4
marked this pull request as ready for review
October 20, 2026 15:21
There was a problem hiding this comment.
Code Review
This pull request refactors the file reference tracking in the library builder compilation pipeline and improves AOT compilation state persistence by tracking emitted d.ts source files in a WeakSet across compilations instead of using a local Set. Additionally, a new integration test has been added to verify rebuilding behavior and recovery from template errors when external Sass partials or templates are modified. I have no feedback to provide as there are no review comments.
alan-agius4
force-pushed
the
perf/library-external-resource-fast-path
branch
from
October 20, 2026 16:37
caadb0e to
ee01c14
Compare
dgp1130
approved these changes
Oct 21, 2026
…nal resource edits Register external stylesheet dependencies on `stylesheetFile ?? containingFile` in the library builder so modifying an external stylesheet or imported SCSS partial does not add the component `.ts` file to `effectiveModifiedFiles` and evict it from `TypeScriptCompilation`'s AST cache. Instead, `getResourceDependencies` maps the modified stylesheet back to the component `.ts` file via `resourceModifiedFiles` while reusing the cached `ts.SourceFile` AST. Additionally, persist a `WeakSet<ts.SourceFile>` of emitted declaration files on `AngularCompilationState` across incremental watch builds so that unchanged `ts.SourceFile`s re-emitted solely due to external resource edits (`templateUrl` / `styleUrl`) pass `EmitOnly.Js` to `program.emit`, skipping redundant `.d.ts` generation and downstream declaration processing.
alan-agius4
force-pushed
the
perf/library-external-resource-fast-path
branch
from
October 21, 2026 06:28
ee01c14 to
95c28b8
Compare
Collaborator
Author
|
This PR was merged into the repository. The changes were merged into the following branches:
|
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.
This PR implements two watch-mode incremental build optimizations for external Angular component resources (
templateUrlandstyleUrl):Register external stylesheet dependencies on
stylesheetFile ?? containingFile:Previously,
transformStylesheetin the library builder registeredresult.referencedFilesdirectly againstcontainingFile(the component.tsfile). Editing an external stylesheet or an imported SCSS partial therefore added the component.tsfile toeffectiveModifiedFiles, evicting the.tsfile fromTypeScriptCompilation's AST cache and forcing TypeScript to re-read and re-parse the.tsfile on disk. By registering external stylesheet references onstylesheetFile ?? containingFile,expandModifiedFilesexpands an edited_partial.scsstocomp.scss, whichgetResourceDependenciesthen maps tocomp.tsviaresourceModifiedFileswithout evicting the cachedts.SourceFileAST.Skip
.d.tsre-emit (EmitOnly.Js) for unchangedts.SourceFiles on resource-only edits:Persists a
WeakSet<ts.SourceFile>(emittedDtsSourceFiles) onAngularCompilationStateacross incremental watch builds. When a component'sts.SourceFileobject is unchanged in memory (i.e. only its external.htmltemplate or.scss/.cssstylesheet was modified), the fallback emit loop passesEmitOnly.Jstoprogram.emit(), skipping redundant.d.tsgeneration and downstream declaration bundling/processing.