Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@vitejs/plugin-basic-ssl": "2.3.0",
"beasties": "0.5.5",
"browserslist": "^4.26.0",
"chokidar": "5.0.0",
"chokidar": "6.0.0",
"esbuild": "0.28.2",
"https-proxy-agent": "9.1.0",
"jsonc-parser": "3.3.1",
Expand Down
24 changes: 16 additions & 8 deletions packages/angular/build/src/utils/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,20 @@ export function getDirectoryPath(posixPath: string): string {
return dir;
}

function isNodeModulesSegment(lookupKey: string): boolean {
return lookupKey === NODE_MODULES || lookupKey.endsWith(`/${NODE_MODULES}`);
}

/**
* Determines whether a file path lookup key or any of its parent directories are present in watchedFiles.
*/
function isPathWatched(fileLookupKey: string, watchedFiles: Set<string>): boolean {
function isPathWatched(fileLookupKey: string, watchedFiles: ReadonlySet<string>): boolean {
if (watchedFiles.has(fileLookupKey)) {
return true;
}

let current = fileLookupKey;
while (true) {
while (!isNodeModulesSegment(current)) {
const parent = getDirectoryPath(current);
if (parent === current) {
break;
Expand Down Expand Up @@ -1111,8 +1115,8 @@ function createChokidarIgnored(
}) ?? [];

// When watching a directory (e.g. projectRoot via NG_BUILD_WATCH_ROOT), prune `node_modules`
// directories unless explicitly added to `watchedFiles`. Explicitly added files inside
// `node_modules` do not end with `/node_modules` and remain watchable.
// directories and any unwatched descendants inside `node_modules` (since Chokidar 6 keeps
// ancestor directories of explicitly watched package files un-ignored to traverse to them).
return [
...customIgnored,
(filePath: string) => {
Expand All @@ -1122,11 +1126,15 @@ function createChokidarIgnored(

const posixPath = toPosixPathNormalized(filePath);
const lookupKey = toLookupKey(posixPath, isCaseSensitive);
if (
!isNodeModulesSegment(lookupKey) &&
!lookupKey.includes(`/${NODE_MODULES}/`) &&
!lookupKey.startsWith(`${NODE_MODULES}/`)
) {
return false;
}

return (
(lookupKey === NODE_MODULES || lookupKey.endsWith(`/${NODE_MODULES}`)) &&
!watchedFiles.has(lookupKey)
);
return !isPathWatched(lookupKey, watchedFiles);
},
];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"source-map": "0.8.0"
},
"devDependencies": {
"chokidar": "5.0.0"
"chokidar": "6.0.0"
},
"peerDependencies": {
"chokidar": "^5.0.0"
"chokidar": "^6.0.0"
},
"peerDependenciesMeta": {
"chokidar": {
Expand Down
16 changes: 12 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading