Skip to content

Commit dddf318

Browse files
alan-agius4mgechev
authored andcommitted
fix(@ngtools/webpack): avoid re-running full emit when there wasn't a an emit
There can be a number of reason why `_emitSkipped` is set to true these are: - Errors have been encountered - Changes are outside of TS compilations such as HTML and CSS in JIT mode We only want to run a full JIT emit when; - There hasn't been a success emit - When a large number of files have changed - First run If a subsequent JIT build fails we shouldn't do a full emit either as we will transpile only the files that changes after the success build https://github.com/angular/angular-cli/blob/64243919c10c33775be71010efd5ae69622a728f/packages/ngtools/webpack/src/angular_compiler_plugin.ts#L1029-L1031 Fixes angular#14775
1 parent b85ec94 commit dddf318

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/angular_compiler_plugin.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export class AngularCompilerPlugin {
107107
private _platform: PLATFORM;
108108
private _JitMode = false;
109109
private _emitSkipped = true;
110+
// This is needed because if the first build fails we need to do a full emit
111+
// even whe only a single file gets updated.
112+
private _hadFullJitEmit: boolean | undefined;
110113
private _changedFileExtensions = new Set(['ts', 'tsx', 'html', 'css', 'js', 'json']);
111114

112115
// Webpack plugin.
@@ -1196,14 +1199,15 @@ export class AngularCompilerPlugin {
11961199
'AngularCompilerPlugin._emit.ts', diagMode));
11971200

11981201
if (!hasErrors(allDiagnostics)) {
1199-
if (this._firstRun || changedTsFiles.size > 20 || this._emitSkipped) {
1202+
if (this._firstRun || changedTsFiles.size > 20 || !this._hadFullJitEmit) {
12001203
emitResult = tsProgram.emit(
12011204
undefined,
12021205
undefined,
12031206
undefined,
12041207
undefined,
12051208
{ before: this._transformers },
12061209
);
1210+
this._hadFullJitEmit = !emitResult.emitSkipped;
12071211
allDiagnostics.push(...emitResult.diagnostics);
12081212
} else {
12091213
for (const changedFile of changedTsFiles) {

0 commit comments

Comments
 (0)