From 06cd33303a512397eda8a41678beb2f94471713a Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 31 Jul 2019 17:55:15 +0100 Subject: [PATCH] fix(@angular-devkit/build-angular): use GLOBAL_DEFS_FOR_TERSER_WITH_AOT if present Fix #15206 --- .../models/webpack-configs/common.ts | 17 +++++++++++++++++ 1 file changed, 17 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 9afad63c7cc3..d7a8e17b3f20 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 @@ -308,6 +308,23 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { // Do nothing, the default above will be used instead. } + if (buildOptions.aot) { + // Also try to load AOT-only global definitions. + try { + // tslint:disable-next-line:no-implicit-dependencies + const GLOBAL_DEFS_FOR_TERSER_WITH_AOT = + require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER_WITH_AOT; + if (GLOBAL_DEFS_FOR_TERSER_WITH_AOT) { + angularGlobalDefinitions = { + ...angularGlobalDefinitions, + ...GLOBAL_DEFS_FOR_TERSER_WITH_AOT, + }; + } + } catch { + // Do nothing. + } + } + const terserOptions = { ecma: wco.supportES2015 ? 6 : 5, warnings: !!buildOptions.verbose,