mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
avoid computing a full shape for indirectly invalidated files (#44090)
* add shape updates to baselines * avoid computing a full shape for indirectly invalidated files using file version as shape is enough to keep build info valid and it's much cheaper
This commit is contained in:
@@ -478,6 +478,7 @@ namespace ts {
|
||||
// we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file
|
||||
// This ensures that we dont later during incremental builds considering wrong signature.
|
||||
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
||||
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
||||
BuilderState.updateShapeSignature(
|
||||
state,
|
||||
program,
|
||||
@@ -485,7 +486,8 @@ namespace ts {
|
||||
Debug.checkDefined(state.currentAffectedFilesSignatures),
|
||||
cancellationToken,
|
||||
computeHash,
|
||||
state.currentAffectedFilesExportedModulesMap
|
||||
state.currentAffectedFilesExportedModulesMap,
|
||||
/* useFileVersionAsSignature */ true
|
||||
);
|
||||
// If not dts emit, nothing more to do
|
||||
if (getEmitDeclarations(state.compilerOptions)) {
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace ts {
|
||||
/**
|
||||
* Returns if the shape of the signature has changed since last emit
|
||||
*/
|
||||
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ManyToManyPathMap) {
|
||||
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ManyToManyPathMap, useFileVersionAsSignature: boolean = state.useFileVersionAsSignature) {
|
||||
Debug.assert(!!sourceFile);
|
||||
Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
|
||||
|
||||
@@ -412,7 +412,7 @@ namespace ts {
|
||||
|
||||
const prevSignature = info.signature;
|
||||
let latestSignature: string | undefined;
|
||||
if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) {
|
||||
if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
|
||||
const emitOutput = getFileEmitOutput(
|
||||
programOfThisState,
|
||||
sourceFile,
|
||||
|
||||
@@ -468,6 +468,7 @@ namespace ts.tscWatch {
|
||||
if (!builderProgram) return;
|
||||
if (builderProgram !== oldProgram?.[1]) {
|
||||
const state = builderProgram.getState();
|
||||
const internalState = state as unknown as BuilderState;
|
||||
if (state.semanticDiagnosticsPerFile?.size) {
|
||||
baseline.push("Semantic diagnostics in builder refreshed for::");
|
||||
for (const file of program.getSourceFiles()) {
|
||||
@@ -479,6 +480,24 @@ namespace ts.tscWatch {
|
||||
else {
|
||||
baseline.push("No cached semantic diagnostics in the builder::");
|
||||
}
|
||||
if (internalState) {
|
||||
baseline.push("");
|
||||
if (internalState.hasCalledUpdateShapeSignature?.size) {
|
||||
baseline.push("Shape signatures in builder refreshed for::");
|
||||
internalState.hasCalledUpdateShapeSignature.forEach((path: Path) => {
|
||||
const info = state.fileInfos.get(path);
|
||||
if(info?.version === info?.signature || !info?.signature) {
|
||||
baseline.push(path + " (used version)");
|
||||
}
|
||||
else {
|
||||
baseline.push(path + " (computed .d.ts)");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
baseline.push("No shapes updated in the builder::");
|
||||
}
|
||||
}
|
||||
baseline.push("");
|
||||
if (!baselineDependencies) return;
|
||||
baseline.push("Dependencies for::");
|
||||
|
||||
Reference in New Issue
Block a user