Skip to content

Commit 0d9038c

Browse files
committed
Handle prepend in incremental build. Always emit when program uses project reference with prepend since it cant tell changes in js/map files
1 parent 7b290fd commit 0d9038c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/compiler/builder.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ namespace ts {
6666
* Already seen affected files
6767
*/
6868
seenEmittedFiles: Map<true> | undefined;
69+
/**
70+
* true if program has been emitted
71+
*/
72+
programEmitComplete?: true;
6973
}
7074

7175
function hasSameKeys<T, U>(map1: ReadonlyMap<T> | undefined, map2: ReadonlyMap<U> | undefined): boolean {
@@ -352,6 +356,7 @@ namespace ts {
352356
function doneWithAffectedFile(state: BuilderProgramState, affected: SourceFile | Program, isPendingEmit?: boolean) {
353357
if (affected === state.program) {
354358
state.changedFilesSet.clear();
359+
state.programEmitComplete = true;
355360
}
356361
else {
357362
state.seenAffectedFiles!.set((affected as SourceFile).path, true);
@@ -487,12 +492,22 @@ namespace ts {
487492
let affected = getNextAffectedFile(state, cancellationToken, computeHash);
488493
let isPendingEmitFile = false;
489494
if (!affected) {
490-
affected = getNextAffectedFilePendingEmit(state);
491-
// Done
492-
if (!affected) {
493-
return undefined;
495+
if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
496+
affected = getNextAffectedFilePendingEmit(state);
497+
if (!affected) {
498+
return undefined;
499+
}
500+
isPendingEmitFile = true;
501+
}
502+
else {
503+
const program = Debug.assertDefined(state.program);
504+
// Check if program uses any prepend project references, if thats the case we cant track of the js files of those, so emit even though there are no changes
505+
if (state.programEmitComplete || !some(program.getProjectReferences(), ref => !!ref.prepend)) {
506+
state.programEmitComplete = true;
507+
return undefined;
508+
}
509+
affected = program;
494510
}
495-
isPendingEmitFile = true;
496511
}
497512

498513
// Mark seen emitted files if there are pending files to be emitted

0 commit comments

Comments
 (0)