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.

Related to angular#9231, angular#11439, angular#12096.
  • Loading branch information
filipesilva committed Apr 16, 2019
1 parent 86b23d7 commit 0f4cf19
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {}),
};

Expand Down

0 comments on commit 0f4cf19

Please sign in to comment.