Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ namespace ts {
const configFileCache = createConfigFileCache(host);
let context = createBuildContext(defaultOptions);
let timerToBuildInvalidatedProject: any;
let reportFileChangeDetected = false;

const existingWatchersForWildcards = createMap<WildcardDirectoryWatcher>();
return {
Expand Down Expand Up @@ -584,7 +585,7 @@ namespace ts {
}

function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) {
reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation);
reportFileChangeDetected = true;
invalidateProject(resolved);
scheduleBuildInvalidatedProject();
}
Expand Down Expand Up @@ -817,6 +818,10 @@ namespace ts {

function buildInvalidatedProject() {
timerToBuildInvalidatedProject = undefined;
if (reportFileChangeDetected) {
reportFileChangeDetected = false;
reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation);
}
const buildProject = context.getNextInvalidatedProject();
buildSomeProjects(p => p === buildProject);
if (context.hasPendingInvalidatedProjects()) {
Expand Down
13 changes: 13 additions & 0 deletions src/testRunner/unittests/tsbuildWatchMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,22 @@ export class someClass { }`);
// Another change requeues and builds it
verifyChange(core[1].content);

// Two changes together report only single time message: File change detected. Starting incremental compilation...
const outputFileStamps = getOutputFileStamps(host);
const change1 = `${core[1].content}
export class someClass { }`;
host.writeFile(core[1].path, change1);
host.writeFile(core[1].path, `${change1}
export class someClass2 { }`);
verifyChangeAfterTimeout(outputFileStamps);

function verifyChange(coreContent: string) {
const outputFileStamps = getOutputFileStamps(host);
host.writeFile(core[1].path, coreContent);
verifyChangeAfterTimeout(outputFileStamps);
}

function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[]) {
host.checkTimeoutQueueLengthAndRun(1); // Builds core
const changedCore = getOutputFileStamps(host);
verifyChangedFiles(changedCore, outputFileStamps, [
Expand Down