Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ignore node modules when polling
Browse files Browse the repository at this point in the history
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%.
  • Loading branch information
clydin authored and mgechev committed Nov 12, 2019
1 parent 6c2d956 commit 2d9ee82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
watch: buildOptions.watch,
watchOptions: {
poll: buildOptions.poll,
ignored: buildOptions.poll === undefined ? undefined : /[\\\/]node_modules[\\\/]/,
},
performance: {
hints: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,11 @@ export function buildServerConfig(
stats: false,
compress: styles || scripts,
watchOptions: {
poll: browserOptions.poll,
// Using just `--poll` will result in a value of 0 which is very likely not the intention
// A value of 0 is falsy and will disable polling rather then enable
// 500 ms is a sensible default in this case
poll: serverOptions.poll === 0 ? 500 : serverOptions.poll,
ignored: serverOptions.poll === undefined ? undefined : /[\\\/]node_modules[\\\/]/,
},
https: serverOptions.ssl,
overlay: {
Expand Down

0 comments on commit 2d9ee82

Please sign in to comment.