Skip to content

Commit 06763bb

Browse files
committed
fix(@angular-devkit/build-angular): ignore node modules when polling
The node modules directory contains a massive set of directories and files. When watching via polling, that set needs to be queried repeatedly to determine if any files have changed. Changes within node modules are quite rare while using `ng serve` or `ng build --watch`. As a result, polling the node modules directory is rarely useful. This change causes CPU usage to drop from a potential high of ~80% to a more manageable ~5-10%.
1 parent 862b28f commit 06763bb

File tree

2 files changed

+6
-1
lines changed
  • packages/angular_devkit/build_angular/src

2 files changed

+6
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
479479
watch: buildOptions.watch,
480480
watchOptions: {
481481
poll: buildOptions.poll,
482+
ignored: buildOptions.poll === undefined ? undefined : /[\\\/]node_modules[\\\/]/,
482483
},
483484
performance: {
484485
hints: false,

packages/angular_devkit/build_angular/src/dev-server/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,11 @@ export function buildServerConfig(
423423
stats: false,
424424
compress: styles || scripts,
425425
watchOptions: {
426-
poll: browserOptions.poll,
426+
// Using just `--poll` will result in a value of 0 which is very likely not the intention
427+
// A value of 0 is falsy and will disable polling rather then enable
428+
// 500 ms is a sensible default in this case
429+
poll: serverOptions.poll === 0 ? 500 : serverOptions.poll,
430+
ignored: serverOptions.poll === undefined ? undefined : /[\\\/]node_modules[\\\/]/,
427431
},
428432
https: serverOptions.ssl,
429433
overlay: {

0 commit comments

Comments
 (0)