Skip to content

Commit 36e541c

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 #14775
1 parent af93227 commit 36e541c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

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

111114
// Webpack plugin.
@@ -1191,14 +1194,15 @@ export class AngularCompilerPlugin {
11911194
'AngularCompilerPlugin._emit.ts', diagMode));
11921195

11931196
if (!hasErrors(allDiagnostics)) {
1194-
if (this._firstRun || changedTsFiles.size > 20 || this._emitSkipped) {
1197+
if (this._firstRun || changedTsFiles.size > 20 || !this._hadFullJitEmit) {
11951198
emitResult = tsProgram.emit(
11961199
undefined,
11971200
undefined,
11981201
undefined,
11991202
undefined,
12001203
{ before: this._transformers },
12011204
);
1205+
this._hadFullJitEmit = !emitResult.emitSkipped;
12021206
allDiagnostics.push(...emitResult.diagnostics);
12031207
} else {
12041208
for (const changedFile of changedTsFiles) {

0 commit comments

Comments
 (0)