Skip to content

Do not write build info if there are no files to emit #34487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 17, 2019
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
1 change: 1 addition & 0 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ namespace ts {
state.seenAffectedFiles = createMap<true>();
}

state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
return state;
}

Expand Down
8 changes: 7 additions & 1 deletion src/testRunner/unittests/tsc/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,15 @@ namespace ts {
Initial = "initial-build",
IncrementalDtsChange = "incremental-declaration-changes",
IncrementalDtsUnchanged = "incremental-declaration-doesnt-change",
IncrementalHeadersChange = "incremental-headers-change-without-dts-changes"
IncrementalHeadersChange = "incremental-headers-change-without-dts-changes",
NoChangeRun ="no-change-run"
}

export const noChangeRun: TscIncremental = {
buildKind: BuildKind.NoChangeRun,
modifyFs: noop
};

export interface TscCompile {
scenario: string;
subScenario: string;
Expand Down
26 changes: 21 additions & 5 deletions src/testRunner/unittests/tsc/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ namespace ts {
}`,
}),
commandLineArgs: ["--incremental", "--p", "src/project", "--tsBuildInfoFile", "src/project/.tsbuildinfo"],
incrementalScenarios: [{
buildKind: BuildKind.IncrementalDtsUnchanged,
modifyFs: noop,
}]
incrementalScenarios: [noChangeRun]
});

verifyTsc({
verifyTscIncrementalEdits({
scenario: "incremental",
subScenario: "when passing rootDir from commandline",
fs: () => loadProjectFromFiles({
Expand All @@ -37,6 +34,25 @@ namespace ts {
}`,
}),
commandLineArgs: ["--p", "src/project", "--rootDir", "src/project/src"],
incrementalScenarios: [noChangeRun]
});

verifyTscIncrementalEdits({
scenario: "incremental",
subScenario: "with only dts files",
fs: () => loadProjectFromFiles({
"/src/project/src/main.d.ts": "export const x = 10;",
"/src/project/src/another.d.ts": "export const y = 10;",
"/src/project/tsconfig.json": "{}",
}),
commandLineArgs: ["--incremental", "--p", "src/project"],
incrementalScenarios: [
noChangeRun,
{
buildKind: BuildKind.IncrementalDtsUnchanged,
modifyFs: fs => appendText(fs, "/src/project/src/main.d.ts", "export const xy = 100;")
}
]
});
});
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//// [/lib/incremental-declaration-doesnt-changeOutput.txt]
/lib/tsc --incremental --p src/project
exitCode:: 0


//// [/src/project/src/main.d.ts]
export const x = 10;export const xy = 100;

//// [/src/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
},
"./src/another.d.ts": {
"version": "-13729955264-export const y = 10;",
"signature": "-13729955264-export const y = 10;"
},
"./src/main.d.ts": {
"version": "-10808461502-export const x = 10;export const xy = 100;",
"signature": "-10808461502-export const x = 10;export const xy = 100;"
}
},
"options": {
"incremental": true,
"project": "./",
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./src/another.d.ts",
"./src/main.d.ts"
]
},
"version": "FakeTSVersion"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//// [/lib/initial-buildOutput.txt]
/lib/tsc --incremental --p src/project
exitCode:: 0


//// [/src/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };"
},
"./src/another.d.ts": {
"version": "-13729955264-export const y = 10;",
"signature": "-13729955264-export const y = 10;"
},
"./src/main.d.ts": {
"version": "-10726455937-export const x = 10;",
"signature": "-10726455937-export const x = 10;"
}
},
"options": {
"incremental": true,
"project": "./",
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./src/another.d.ts",
"./src/main.d.ts"
]
},
"version": "FakeTSVersion"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//// [/lib/no-change-runOutput.txt]
/lib/tsc --incremental --p src/project --tsBuildInfoFile src/project/.tsbuildinfo
exitCode:: 0


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//// [/lib/no-change-runOutput.txt]
/lib/tsc --p src/project --rootDir src/project/src
exitCode:: 0


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//// [/lib/no-change-runOutput.txt]
/lib/tsc --incremental --p src/project
exitCode:: 0