Repository navigation
fix(@angular/build): prevent chokidar from scanning unimported node_modules in watch mode - #34168
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the file watcher to support detecting changes in linked packages inside node_modules (such as those created via npm link) when preserveSymlinks is enabled, while continuing to ignore unimported packages. The feedback focuses on addressing a potential watcher leak when packages are removed by implementing reference counting, and optimizing performance by avoiding expensive path normalization in isNodeModulesIgnored through a quick initial string check.
a797fb2 to
df9dfab
Compare
df9dfab to
3db30e3
Compare
…odules in watch mode When using Chokidar (such as when `preserveSymlinks: true` is configured or polling is active), Chokidar's initial filesystem scan previously walked the entire `workspaceRoot`, including all of `node_modules`. Because `await once(watcher, 'ready')` blocks until the initial scan completes, this caused watch mode in commands like `ng test`, `ng serve`, and `ng build --watch` to hang for minutes before emitting the first build result. This commit introduces selective `node_modules` filtering in Chokidar: - `node_modules` packages corresponding to imported build files (e.g. `npm link` libraries, both unscoped and scoped) are allowed and their directories watched, retaining native symlink traversal. - All other unimported subdirectories in `node_modules` are pruned and ignored during the initial scan and subsequent directory visits. - Packages added dynamically via `watcher.add()` are registered and watched on the fly. Fixes angular#34162
3db30e3 to
dcd5c67
Compare
|
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. |
When using Chokidar (such as when
preserveSymlinks: trueis configured or polling is active), Chokidar's initial filesystem scan previously walked the entireworkspaceRoot, including all ofnode_modules. Becauseawait once(watcher, 'ready')blocks until the initial scan completes, this caused watch mode in commands likeng test,ng serve, andng build --watchto hang for minutes before emitting the first build result.Fixes #34162