Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): remove pure_getters
Browse files Browse the repository at this point in the history
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.

Closes angular#9231, angular#11439, angular#12096, angular#12128.
  • Loading branch information
filipesilva committed Apr 24, 2019
1 parent a53b206 commit 88fc7f6
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,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 } : {}),
};

Expand Down

0 comments on commit 88fc7f6

Please sign in to comment.