Skip to content

Commit dc65268

Browse files
angular-robotclydin
authored andcommitted
build: update dependency chokidar to v6
See associated pull request for more information. Closes #34464 as a pr takeover
1 parent a38958c commit dc65268

4 files changed

Lines changed: 31 additions & 15 deletions

File tree

‎packages/angular/build/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@vitejs/plugin-basic-ssl": "2.3.0",
2727
"beasties": "0.5.5",
2828
"browserslist": "^4.26.0",
29-
"chokidar": "5.0.0",
29+
"chokidar": "6.0.0",
3030
"esbuild": "0.28.2",
3131
"https-proxy-agent": "9.1.0",
3232
"jsonc-parser": "3.3.1",

‎packages/angular/build/src/utils/watcher.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,20 @@ export function getDirectoryPath(posixPath: string): string {
219219
return dir;
220220
}
221221

222+
function isNodeModulesSegment(lookupKey: string): boolean {
223+
return lookupKey === NODE_MODULES || lookupKey.endsWith(`/${NODE_MODULES}`);
224+
}
225+
222226
/**
223227
* Determines whether a file path lookup key or any of its parent directories are present in watchedFiles.
224228
*/
225-
function isPathWatched(fileLookupKey: string, watchedFiles: Set<string>): boolean {
229+
function isPathWatched(fileLookupKey: string, watchedFiles: ReadonlySet<string>): boolean {
226230
if (watchedFiles.has(fileLookupKey)) {
227231
return true;
228232
}
229233

230234
let current = fileLookupKey;
231-
while (true) {
235+
while (!isNodeModulesSegment(current)) {
232236
const parent = getDirectoryPath(current);
233237
if (parent === current) {
234238
break;
@@ -1111,8 +1115,8 @@ function createChokidarIgnored(
11111115
}) ?? [];
11121116

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

11231127
const posixPath = toPosixPathNormalized(filePath);
11241128
const lookupKey = toLookupKey(posixPath, isCaseSensitive);
1129+
if (
1130+
!isNodeModulesSegment(lookupKey) &&
1131+
!lookupKey.includes(`/${NODE_MODULES}/`) &&
1132+
!lookupKey.startsWith(`${NODE_MODULES}/`)
1133+
) {
1134+
return false;
1135+
}
11251136

1126-
return (
1127-
(lookupKey === NODE_MODULES || lookupKey.endsWith(`/${NODE_MODULES}`)) &&
1128-
!watchedFiles.has(lookupKey)
1129-
);
1137+
return !isPathWatched(lookupKey, watchedFiles);
11301138
},
11311139
];
11321140
}

‎packages/angular_devkit/core/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"source-map": "0.8.0"
3434
},
3535
"devDependencies": {
36-
"chokidar": "5.0.0"
36+
"chokidar": "6.0.0"
3737
},
3838
"peerDependencies": {
39-
"chokidar": "^5.0.0"
39+
"chokidar": "^6.0.0"
4040
},
4141
"peerDependenciesMeta": {
4242
"chokidar": {

‎pnpm-lock.yaml‎

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)