Skip to content

Commit 230c686

Browse files
committed
fix(@ngtools/webpack): don't use skipTemplateCodegen to determine if compilation is JIT mode
With this change we add a new `jitMode` option to the ivy AngularWebpackPlugin. `readConfiguration` from `@angular/compiler-cli` will use file configuration options over programmaticly supplied options. By using a separate option the options precedence issue can be avoided. Closes #19949 (cherry picked from commit d2ce3e7)
1 parent 79df3bd commit 230c686

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ function createIvyPlugin(
5959
const optimize = buildOptions.optimization.scripts;
6060

6161
const compilerOptions: CompilerOptions = {
62-
skipTemplateCodegen: !aot,
6362
sourceMap: buildOptions.sourceMap.scripts,
6463
};
6564

@@ -78,6 +77,7 @@ function createIvyPlugin(
7877
tsconfig,
7978
compilerOptions,
8079
fileReplacements,
80+
jitMode: !aot,
8181
emitNgModuleScope: !optimize,
8282
});
8383
}

packages/ngtools/webpack/src/ivy/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface AngularPluginOptions {
4444
emitClassMetadata: boolean;
4545
emitNgModuleScope: boolean;
4646
suppressZoneJsIncompatibilityWarning: boolean;
47+
jitMode: boolean;
4748
}
4849

4950
// Add support for missing properties in Webpack types as well as the loader's file emitter
@@ -91,6 +92,7 @@ export class AngularWebpackPlugin {
9192
this.pluginOptions = {
9293
emitClassMetadata: false,
9394
emitNgModuleScope: false,
95+
jitMode: false,
9496
fileReplacements: {},
9597
substitutions: {},
9698
directTemplateLoading: true,
@@ -222,7 +224,7 @@ export class AngularWebpackPlugin {
222224
augmentHostWithSubstitutions(host, this.pluginOptions.substitutions);
223225

224226
// Create the file emitter used by the webpack loader
225-
const { fileEmitter, builder, internalFiles } = compilerOptions.skipTemplateCodegen
227+
const { fileEmitter, builder, internalFiles } = this.pluginOptions.jitMode
226228
? this.updateJitProgram(compilerOptions, rootNames, host, diagnosticsReporter)
227229
: this.updateAotProgram(
228230
compilerOptions,

0 commit comments

Comments
 (0)