Skip to content

fix(@angular/build): rebuild library when transitive stylesheet dependencies change in watch mode - #34356

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:library-watch-style-refs
Oct 15, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:library-watch-style-refs

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Track transitive stylesheet resource references per containing component and stylesheet file in BuilderState.addFileReferences, and resolve affected files via BuilderState.getAffectedFiles during watch mode rebuilds.

Previously, modifying a Sass partial imported by an inline component stylesheet did not invalidate the containing component file or reset the Sass worker pool cache.

@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Oct 15, 2026
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

/gemini review

@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 library builder's incremental compilation and watch-mode state management. It introduces the BuilderState class to encapsulate incremental compilation state, transitive resource reference tracking, and watched files, alongside the ExecutionResult class to manage diagnostic messages and build status. The pipeline files, including builder.ts, build-action.ts, and compilation.ts, have been updated to utilize these new classes, simplifying the overall architecture and improving maintainability. Additionally, comprehensive unit and behavior tests have been added to verify the new state management and watch-mode rebuilding. No review comments were provided, so there is no feedback to evaluate.

@alan-agius4
alan-agius4 force-pushed the library-watch-style-refs branch 3 times, most recently from 08f2f8e to 930a706 Compare October 15, 2026 14:53
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 15, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 15, 2026 14:53

@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 introduces transitive resource dependency tracking to the library builder, enabling more accurate incremental builds in watch mode when stylesheet dependencies (like Sass partials) are modified. The changes include adding reference tracking to BuilderState, updating the watch loop to utilize these references, and adding comprehensive tests to verify the behavior. A critical issue was identified in the watch loop implementation where invalidatedStyles (an iterable) was incorrectly treated as an array, which would cause a runtime error; this has been flagged for correction.

Comment thread packages/angular/build/src/builders/library/builder.ts Outdated
@alan-agius4
alan-agius4 requested a review from clydin October 15, 2026 15:23
@alan-agius4
alan-agius4 force-pushed the library-watch-style-refs branch 2 times, most recently from 3222521 to 52614da Compare October 15, 2026 15:36
Comment thread packages/angular/build/src/builders/library/pipeline/compilation.ts
…dencies change in watch mode

Track transitive stylesheet resource references per containing component and stylesheet file in `BuilderState.addFileReferences`, and resolve affected files via `BuilderState.getAffectedFiles` during watch mode rebuilds.

Previously, modifying a Sass partial imported by an inline component stylesheet did not invalidate the containing component file or reset the Sass worker pool cache.
@alan-agius4
alan-agius4 force-pushed the library-watch-style-refs branch from 52614da to 01241a1 Compare October 15, 2026 17:44
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 15, 2026
@alan-agius4
alan-agius4 merged commit 93f238c into angular:main Oct 15, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the library-watch-style-refs branch October 15, 2026 18:02
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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.

2 participants