Skip to content

fix(@angular/build): align library watch asset matching with initial build and deduplicate outputs - #34432

Merged
alan-agius4 merged 4 commits into
angular:mainfrom
alan-agius4:fix/library-assets-watch-and-dedup
Oct 21, 2026
Merged

alan-agius4 merged 4 commits into
angular:mainfrom
alan-agius4:fix/library-assets-watch-and-dedup

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Summary

  • Respect asset.followSymlinks in watch mode (collectAssetsToEmit) by using lstatSync when !asset.followSymlinks and statSync when asset.followSymlinks is true (caching stat and lstat separately per file).
  • Normalize asset.glob and asset.ignore in createAssetMatchers to match tinyglobby semantics on initial build (filtering empty strings, expanding directory patterns with /**, normalizing via posix.normalize, and setting windows: false).
  • Deduplicate resolved and collected assets by destination path (allowing later asset configurations to override earlier ones) to prevent concurrent fs.cp calls to the same destination.
  • Handle directory deletion in watch mode by queuing nested emitted assets under a deleted directory path for deletion.

…build and deduplicate outputs

- Respect `asset.followSymlinks` in watch mode by using `lstatSync` when `!asset.followSymlinks` and `statSync` when `asset.followSymlinks` is `true`.
- Normalize `asset.glob` and `asset.ignore` patterns in `createAssetMatchers` to match `tinyglobby` semantics (stripping trailing slashes, expanding directory patterns with `/**`, normalizing POSIX paths, skipping empty strings, and passing `windows: false`).
- Deduplicate collected and resolved assets by destination `path` so later asset configurations override earlier ones without concurrent `fs.cp` operations to the same output destination.
- Queue nested emitted assets for deletion when a deleted parent directory is reported in watch mode.
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Oct 20, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 20, 2026 10:28
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 10: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 enhances asset handling in the Angular library builder by introducing a normalizeGlobPattern utility and updating createAssetMatchers and collectAssetsToEmit to improve support for symlinks and directory deletion tracking in watch mode. Comprehensive unit tests were added to verify these changes. A high-severity issue was identified in the normalizeGlobPattern function, where it incorrectly appends /** to file glob patterns; the reviewer provided a necessary fix using picomatch.isGlob to ensure correct matching behavior.

Comment thread packages/angular/build/src/builders/library/pipeline/assets.ts
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 21, 2026
@alan-agius4
alan-agius4 merged commit a38958c into angular:main Oct 21, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix/library-assets-watch-and-dedup branch October 21, 2026 16:26
@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 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.

2 participants