From 57695458a54168147ade5438385f265791cd8627 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Fri, 17 Jul 2020 21:04:10 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): mark rxjs add imports as having side effects This change prevents webpack 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. --- .../src/angular-cli-files/models/webpack-configs/common.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts index dd2ea23014aa..3abd95d55278 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts @@ -526,6 +526,13 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/, parser: { system: true }, }, + { + // Mark files inside `rxjs/add` as containing side effects. + // If this is fixed upstream and the fixed version becomes the minimum + // supported version, this can be removed. + test: /[\/\\]rxjs[\/\\]add[\/\\].+\.js$/, + sideEffects: true, + }, { test: /\.m?js$/, exclude: [/[\/\\](?:core-js|\@babel|tslib)[\/\\]/, /(ngfactory|ngstyle)\.js$/],