Skip to content

Commit

Permalink
fix(@ngtools/webpack): don't use skipTemplateCodegen to determine i…
Browse files Browse the repository at this point in the history
…f 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)
  • Loading branch information
alan-agius4 committed Feb 3, 2021
1 parent 79df3bd commit 230c686
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -59,7 +59,6 @@ function createIvyPlugin(
const optimize = buildOptions.optimization.scripts;

const compilerOptions: CompilerOptions = {
skipTemplateCodegen: !aot,
sourceMap: buildOptions.sourceMap.scripts,
};

Expand All @@ -78,6 +77,7 @@ function createIvyPlugin(
tsconfig,
compilerOptions,
fileReplacements,
jitMode: !aot,
emitNgModuleScope: !optimize,
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/ngtools/webpack/src/ivy/plugin.ts
Expand Up @@ -44,6 +44,7 @@ export interface AngularPluginOptions {
emitClassMetadata: boolean;
emitNgModuleScope: boolean;
suppressZoneJsIncompatibilityWarning: boolean;
jitMode: boolean;
}

// Add support for missing properties in Webpack types as well as the loader's file emitter
Expand Down Expand Up @@ -91,6 +92,7 @@ export class AngularWebpackPlugin {
this.pluginOptions = {
emitClassMetadata: false,
emitNgModuleScope: false,
jitMode: false,
fileReplacements: {},
substitutions: {},
directTemplateLoading: true,
Expand Down Expand Up @@ -222,7 +224,7 @@ export class AngularWebpackPlugin {
augmentHostWithSubstitutions(host, this.pluginOptions.substitutions);

// Create the file emitter used by the webpack loader
const { fileEmitter, builder, internalFiles } = compilerOptions.skipTemplateCodegen
const { fileEmitter, builder, internalFiles } = this.pluginOptions.jitMode
? this.updateJitProgram(compilerOptions, rootNames, host, diagnosticsReporter)
: this.updateAotProgram(
compilerOptions,
Expand Down

0 comments on commit 230c686

Please sign in to comment.