Skip to content

fix(@angular/build): preserve asset precedence and expand glob-prefixed ignores in watch mode - #34470

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/library-assets-followup
Open

clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/library-assets-followup

Conversation

@clydin

@clydin clydin commented Oct 21, 2026

Copy link
Copy Markdown
Member

Previously in library watch mode, ignore patterns containing glob characters that did not end with * (such as **/<dir> or {a,b}) were not expanded with /** because normalizeGlobPattern checked picomatch.scan(result).isGlob. Update normalizeGlobPattern to append /** whenever the stripped pattern does not end with *, matching tinyglobby directory expansion semantics.

In collectAssetsToEmit, incremental watch builds previously only deduplicated colliding output paths among files present in the current modifiedFiles set. Modifying a lower-priority asset could therefore overwrite an existing higher-priority asset on disk, and deleting a higher-priority asset did not restore an existing lower-priority fallback asset. Resolve candidate sources across all asset matchers, evict overridden asset sources in BuilderState.recordEmittedOutputs, and re-emit lower-priority fallback assets when an overriding asset is deleted. Also preserve cached statSync results during deleted-directory checks so a newly created file replacing a directory at the same path is still matched and emitted.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Oct 21, 2026
@clydin
clydin marked this pull request as ready for review October 21, 2026 18:33
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 21, 2026

@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 enhances the Angular library builder's asset tracking and emission logic, particularly in watch mode. It ensures that higher-priority assets are not overwritten by lower-priority ones, restores lower-priority fallback assets when overriding assets are deleted, and correctly handles directory-to-file replacements. Feedback on these changes highlights a potential performance bottleneck in BuilderState where a nested loop introduces an O(N * M) complexity during asset emission; maintaining a reverse mapping of output paths to their emitting sources is recommended to achieve O(1) eviction.

Comment thread packages/angular/build/src/builders/library/builder-state.ts Outdated
…ed ignores in watch mode

Previously in library watch mode, ignore patterns containing glob characters that did not
end with `*` (such as `**/<dir>` or `{a,b}`) were not expanded with `/**` because
`normalizeGlobPattern` checked `picomatch.scan(result).isGlob`. Update
`normalizeGlobPattern` to append `/**` whenever the stripped pattern does not end with
`*`, matching `tinyglobby` directory expansion semantics.

In `collectAssetsToEmit`, incremental watch builds previously only deduplicated colliding
output paths among files present in the current `modifiedFiles` set. Modifying a
lower-priority asset could therefore overwrite an existing higher-priority asset on disk,
and deleting a higher-priority asset did not restore an existing lower-priority fallback
asset. Resolve candidate sources across all asset matchers, evict overridden asset
sources in `BuilderState.recordEmittedOutputs`, and re-emit lower-priority fallback
assets when an overriding asset is deleted. Also preserve cached `statSync` results
during deleted-directory checks so a newly created file replacing a directory at the same
path is still matched and emitted.
@clydin
clydin force-pushed the fix/library-assets-followup branch from 69749ae to 0174a19 Compare October 21, 2026 18:45
@clydin
clydin requested a review from alan-agius4 October 21, 2026 19:15
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