From 0f4cf193dad5b7f62faa5ebfda30be15df4a8c4e Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 16 Apr 2019 15:13:48 +0100 Subject: [PATCH] fix(@angular-devkit/build-angular): remove pure_getters When we first started using Build Optimizer, we saw a lot of the savings were tied to using the Uglify/Terser `pure_getters` option. This was intimately related with the structure and shape of the Angular codebase. The measurements we did at the time on angular.io showed a significant size reduction, from 1mb to about 600kb. Of these roughly 150kb were tied to using `pure_getters` if I remember correctly. Meanwhile the Angular codebase has changed significantly and I don't really see these savings anymore, so I don't think it makes sense to keep it on given that it is known to cause problems with some libraries. Related to #9231, #11439, #12096. --- .../models/webpack-configs/common.ts | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) 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 a679b738151a..072daffd13af 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 @@ -257,25 +257,16 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { comments: false, webkit: true, }, - - // On server, we don't want to compress anything. We still set the ngDevMode = false for it - // to remove dev code, and ngI18nClosureMode to remove Closure compiler i18n code - compress: (buildOptions.platform == 'server' ? { + compress: { + // PURE comments work best with 3 passes. + // See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926. + passes: 3, global_defs: { ngDevMode: false, ngI18nClosureMode: false, }, - } : { - pure_getters: buildOptions.buildOptimizer, - // PURE comments work best with 3 passes. - // See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926. - passes: buildOptions.buildOptimizer ? 3 : 1, - global_defs: { - ngDevMode: false, - ngI18nClosureMode: false, - }, - }), - // We also want to avoid mangling on server. + }, + // We want to avoid mangling on server. ...(buildOptions.platform == 'server' ? { mangle: false } : {}), };