Skip to content

Use .tsbuildinfo to build with tsc and tsc --w when not using build mode #30232

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 7 commits into from
Mar 9, 2019
1,166 changes: 628 additions & 538 deletions lib/tsc.js

Large diffs are not rendered by default.

1,623 changes: 792 additions & 831 deletions lib/tsserver.js

Large diffs are not rendered by default.

1,623 changes: 792 additions & 831 deletions lib/tsserverlibrary.js

Large diffs are not rendered by default.

1,623 changes: 792 additions & 831 deletions lib/typescript.js

Large diffs are not rendered by default.

1,623 changes: 792 additions & 831 deletions lib/typescriptServices.js

Large diffs are not rendered by default.

1,617 changes: 789 additions & 828 deletions lib/typingsInstaller.js

Large diffs are not rendered by default.

18 changes: 2 additions & 16 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,7 @@ namespace ts {
let readFileWithCache = (f: string) => host.readFile(f);
let projectCompilerOptions = baseCompilerOptions;
const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions);
const originalGetSourceFile = compilerHost.getSourceFile;
const computeHash = host.createHash || generateDjb2Hash;
compilerHost.getSourceFile = (...args) => {
const result = originalGetSourceFile.call(compilerHost, ...args);
if (result) {
result.version = computeHash.call(host, result.text);
}
return result;
};
setCreateSourceFileAsHashVersioned(compilerHost, host);

const buildInfoChecked = createFileMap<true>(toPath);

Expand Down Expand Up @@ -1241,13 +1233,7 @@ namespace ts {
function getOldProgram(proj: ResolvedConfigFileName, parsed: ParsedCommandLine) {
const value = builderPrograms.getValue(proj);
if (value) return value;
const buildInfoPath = getOutputPathForBuildInfo(parsed.options);
if (!buildInfoPath) return undefined;
const content = readFileWithCache(buildInfoPath);
if (!content) return undefined;
const buildInfo = getBuildInfo(content);
if (buildInfo.version !== version) return undefined;
return buildInfo.program && createBuildProgramUsingProgramBuildInfo(buildInfo.program) as any as T;
return readBuilderProgram(parsed.options, readFileWithCache) as any as T;
}

function updateBundle(proj: ResolvedConfigFileName): BuildResultFlags {
Expand Down
131 changes: 86 additions & 45 deletions src/compiler/watch.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"unittests/tscWatch/consoleClearing.ts",
"unittests/tscWatch/emit.ts",
"unittests/tscWatch/emitAndErrorUpdates.ts",
"unittests/tscWatch/incremental.ts",
"unittests/tscWatch/programUpdates.ts",
"unittests/tscWatch/resolutionCache.ts",
"unittests/tscWatch/watchEnvironment.ts",
Expand Down
16 changes: 2 additions & 14 deletions src/testRunner/unittests/tsbuild/outFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ namespace ts {
// outputs
...outputFiles[project.first],
...outputFiles[project.second],

// build info
outputFiles[project.third][ext.buildinfo],
],
// These are first not present and later read new contents to generate third output
outputFiles[project.first][ext.buildinfo],
outputFiles[project.second][ext.buildinfo]
]
);

let dtsChangedExpectedDiagnostics: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand All @@ -131,12 +125,8 @@ namespace ts {
...outputFiles[project.first],
...outputFiles[project.second],
outputFiles[project.third][ext.dts],

// build info
outputFiles[project.third][ext.buildinfo],
],
outputFiles[project.first][ext.dts], // dts changes so once read old content, and once new (to emit third)
outputFiles[project.first][ext.buildinfo], // since first build info changes
);

let dtsChangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand Down Expand Up @@ -173,8 +163,7 @@ namespace ts {
...outputFiles[project.first],
...outputFiles[project.second],
...outputFiles[project.third],
],
outputFiles[project.first][ext.buildinfo], // since first build info changes
]
);

let dtsUnchangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand Down Expand Up @@ -227,7 +216,6 @@ namespace ts {
value.set(path, 1);
}
value.set(outputFiles[project.second][ext.dts], 2); // dts changes so once read old content, and once new (to emit third)
value.set(outputFiles[project.second][ext.buildinfo], 2); // since first build info changes
return value;
}

Expand Down
2 changes: 2 additions & 0 deletions src/testRunner/unittests/tscWatch/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace ts.tscWatch {
export interface Watch {
(): Program;
getBuilderProgram(): EmitAndSemanticDiagnosticsBuilderProgram;
close(): void;
}

export function createWatchOfConfigFile(configFileName: string, host: WatchedSystem, maxNumberOfFilesToIterateForInvalidation?: number) {
Expand All @@ -40,6 +41,7 @@ namespace ts.tscWatch {
const watch = createWatchProgram(compilerHost);
const result = (() => watch.getCurrentProgram().getProgram()) as Watch;
result.getBuilderProgram = () => watch.getCurrentProgram();
result.close = () => watch.close();
return result;
}

Expand Down
Loading