diff --git a/packages/angular/build/package.json b/packages/angular/build/package.json index 49cb93d743ac..c320517d3e74 100644 --- a/packages/angular/build/package.json +++ b/packages/angular/build/package.json @@ -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", diff --git a/packages/angular/build/src/utils/watcher.ts b/packages/angular/build/src/utils/watcher.ts index fd865ee80b56..8004c8ac5846 100644 --- a/packages/angular/build/src/utils/watcher.ts +++ b/packages/angular/build/src/utils/watcher.ts @@ -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): boolean { +function isPathWatched(fileLookupKey: string, watchedFiles: ReadonlySet): boolean { if (watchedFiles.has(fileLookupKey)) { return true; } let current = fileLookupKey; - while (true) { + while (!isNodeModulesSegment(current)) { const parent = getDirectoryPath(current); if (parent === current) { break; @@ -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) => { @@ -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); }, ]; } diff --git a/packages/angular_devkit/core/package.json b/packages/angular_devkit/core/package.json index 8145dfe036b6..2d93dde02305 100644 --- a/packages/angular_devkit/core/package.json +++ b/packages/angular_devkit/core/package.json @@ -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": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e60d424b0f55..491a444843e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -499,8 +499,8 @@ importers: specifier: ^4.26.0 version: 4.29.3 chokidar: - specifier: 5.0.0 - version: 5.0.0 + specifier: 6.0.0 + version: 6.0.0 esbuild: specifier: 0.28.2 version: 0.28.2 @@ -926,8 +926,8 @@ importers: version: 0.8.0 devDependencies: chokidar: - specifier: 5.0.0 - version: 5.0.0 + specifier: 6.0.0 + version: 6.0.0 packages/angular_devkit/schematics: dependencies: @@ -4526,6 +4526,10 @@ packages: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} + chokidar@6.0.0: + resolution: {integrity: sha512-Ec2Z7wpcKBiMpR7DxteoqS/sq5G5d2A4fpxzPv6+fD7xNNdrTghn7L11YwV5EN1B3i72Erc3XVT5FkWIDx90+A==} + engines: {node: '>= 22.22'} + chrome-trace-event@1.0.4: resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} engines: {node: '>=6.0'} @@ -12364,6 +12368,10 @@ snapshots: dependencies: readdirp: 5.1.1 + chokidar@6.0.0: + dependencies: + readdirp: 5.1.1 + chrome-trace-event@1.0.4: {} chromium-bidi@157.0.8090-0(devtools-protocol@0.0.1696802):