Skip to content

Commit

Permalink
fix(@angular-devkit/build-optimizer): mark rxjs add imports as having…
Browse files Browse the repository at this point in the history
… side effects

This change prevents the build optimizer from removing the operator add imports from the rxjs package (for example, `import 'rxjs/add/operator/filter';`).  The entire rxjs package is currently marked as side effect free from within the rxjs `package.json` but the files in the add directory intentionally contain side effects.
  • Loading branch information
clydin authored and filipesilva committed Nov 2, 2020
1 parent e70562f commit bee20d2
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -54,6 +54,11 @@ function isKnownCoreFile(filePath: string) {
}

function isKnownSideEffectFree(filePath: string) {
// rxjs add imports contain intentional side effects
if (/[\\/]node_modules[\\/]rxjs[\\/]add[\\/]/.test(filePath)) {
return false;
}

return ngFactories.some((s) => filePath.endsWith(s)) ||
knownSideEffectFreeAngularModules.some((re) => re.test(filePath));
}
Expand Down

0 comments on commit bee20d2

Please sign in to comment.