Skip to content

Commit 06cd333

Browse files
committed
fix(@angular-devkit/build-angular): use GLOBAL_DEFS_FOR_TERSER_WITH_AOT if present
Fix #15206
1 parent 5df50ba commit 06cd333

File tree

1 file changed

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

1 file changed

+17
-0
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,23 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
308308
// Do nothing, the default above will be used instead.
309309
}
310310

311+
if (buildOptions.aot) {
312+
// Also try to load AOT-only global definitions.
313+
try {
314+
// tslint:disable-next-line:no-implicit-dependencies
315+
const GLOBAL_DEFS_FOR_TERSER_WITH_AOT =
316+
require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER_WITH_AOT;
317+
if (GLOBAL_DEFS_FOR_TERSER_WITH_AOT) {
318+
angularGlobalDefinitions = {
319+
...angularGlobalDefinitions,
320+
...GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
321+
};
322+
}
323+
} catch {
324+
// Do nothing.
325+
}
326+
}
327+
311328
const terserOptions = {
312329
ecma: wco.supportES2015 ? 6 : 5,
313330
warnings: !!buildOptions.verbose,

0 commit comments

Comments
 (0)