Repository navigation
fix(@angular/build): avoid expanding directory patterns in asset globs - #34494
Conversation
Previously, when an asset entry specified a directory pattern in `glob` (such as `glob: 'sub/'` or `glob: 'sub'`), its behavior differed depending on whether `ignore` was present: without `ignore`, the static single-file fast-path returned no files, whereas with `ignore`, `tinyglobby` ran with its default `expandDirectories: true` option and recursively matched all files in the directory. This change disables `expandDirectories` for `glob` in `resolveAssets` while preserving directory expansion for `ignore` patterns via a shared `normalizeAssetIgnorePatterns` helper.
There was a problem hiding this comment.
Code Review
This pull request refactors asset resolution and ignore pattern normalization in the Angular build pipeline. It introduces 'normalizeAssetIgnorePatterns' to handle directory-exclusion semantics consistently, ensuring that directory patterns exclude all nested files, and updates the asset matcher and resolver to handle trailing slashes and prevent directory pattern expansion in globs. The review feedback recommends returning a shallow copy of the default ignore patterns array in 'normalizeAssetIgnorePatterns' to prevent potential side-effects from array mutation.
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously, when an asset entry specified a directory pattern in
glob(such asglob: 'sub/'orglob: 'sub'), its behavior differed depending on whetherignorewas present:ignore, the static single-file fast-path checkedstats.isFile()and returned no files.ignore,tinyglobbyran with its defaultexpandDirectories: trueoption and recursively matched all files in the directory.This change disables
expandDirectoriesforglobinresolveAssetswhile preserving directory expansion forignorepatterns via a sharednormalizeAssetIgnorePatternshelper.