Skip to content

Commit 284de6c

Browse files
filipesilvaKeen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): use GLOBAL_DEFS_FOR_TERSER_WITH_AOT if present
Fix #15206
1 parent d212620 commit 284de6c

File tree

1 file changed

+15
-8
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs

1 file changed

+15
-8
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,22 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
297297
ngI18nClosureMode: false,
298298
};
299299

300-
try {
301-
// Try to load known global definitions from @angular/compiler-cli.
302-
// tslint:disable-next-line:no-implicit-dependencies
303-
const GLOBAL_DEFS_FOR_TERSER = require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER;
304-
if (GLOBAL_DEFS_FOR_TERSER) {
305-
angularGlobalDefinitions = GLOBAL_DEFS_FOR_TERSER;
300+
// Try to load known global definitions from @angular/compiler-cli.
301+
const GLOBAL_DEFS_FOR_TERSER = require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER;
302+
if (GLOBAL_DEFS_FOR_TERSER) {
303+
angularGlobalDefinitions = GLOBAL_DEFS_FOR_TERSER;
304+
}
305+
306+
if (buildOptions.aot) {
307+
// Also try to load AOT-only global definitions.
308+
const GLOBAL_DEFS_FOR_TERSER_WITH_AOT =
309+
require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER_WITH_AOT;
310+
if (GLOBAL_DEFS_FOR_TERSER_WITH_AOT) {
311+
angularGlobalDefinitions = {
312+
...angularGlobalDefinitions,
313+
...GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
314+
};
306315
}
307-
} catch {
308-
// Do nothing, the default above will be used instead.
309316
}
310317

311318
const terserOptions = {

0 commit comments

Comments
 (0)