@@ -254,6 +254,20 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
254
254
}
255
255
256
256
if ( scriptsOptimization ) {
257
+ let angularGlobalDefinitions = {
258
+ ngDevMode : false ,
259
+ ngI18nClosureMode : false ,
260
+ } ;
261
+
262
+ try {
263
+ // Try to load known global definitions from @angular /compiler-cli.
264
+ // tslint:disable-next-line:no-implicit-dependencies
265
+ const GLOBAL_DEFS_FOR_TERSER = require ( '@angular/compiler-cli' ) . GLOBAL_DEFS_FOR_TERSER ;
266
+ angularGlobalDefinitions = GLOBAL_DEFS_FOR_TERSER ;
267
+ } catch ( _error ) {
268
+ // Do nothing, the default above will be used instead.
269
+ }
270
+
257
271
const terserOptions = {
258
272
ecma : wco . supportES2015 ? 6 : 5 ,
259
273
warnings : ! ! buildOptions . verbose ,
@@ -267,10 +281,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
267
281
// PURE comments work best with 3 passes.
268
282
// See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
269
283
passes : 3 ,
270
- global_defs : {
271
- ngDevMode : false ,
272
- ngI18nClosureMode : false ,
273
- } ,
284
+ global_defs : angularGlobalDefinitions ,
274
285
} ,
275
286
// We want to avoid mangling on server.
276
287
...( buildOptions . platform == 'server' ? { mangle : false } : { } ) ,
@@ -287,7 +298,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
287
298
}
288
299
289
300
if ( wco . tsConfig . options . target !== undefined &&
290
- wco . tsConfig . options . target >= ts . ScriptTarget . ES2017 ) {
301
+ wco . tsConfig . options . target >= ts . ScriptTarget . ES2017 ) {
291
302
wco . logger . warn ( tags . stripIndent `
292
303
WARNING: Zone.js does not support native async/await in ES2017.
293
304
These blocks are not intercepted by zone.js and will not triggering change detection.
0 commit comments