Skip to content

Commit

Permalink
Use modified time instead of file existence check
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Apr 19, 2022
1 parent 0ff8cb3 commit 59ad6ef
Show file tree
Hide file tree
Showing 165 changed files with 1,774 additions and 3,527 deletions.
2 changes: 0 additions & 2 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ namespace ts {
newestInputFileTime?: Date;
newestInputFileName?: string;
newestDeclarationFileContentChangedTime?: Date;
newestOutputFileTime?: Date;
newestOutputFileName?: string;
oldestOutputFileName: string;
}

Expand Down
36 changes: 14 additions & 22 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,9 @@ namespace ts {
let priorChangeTime: Date | undefined;
if (!anyDtsChanged && isDeclarationFileName(name)) {
// Check for unchanged .d.ts files
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
priorChangeTime = host.getModifiedTime(name);
const modifiedTime = getModifiedTime(host, name);
if (modifiedTime !== missingFileModifiedTime && state.readFileWithCache(name) === text) {
priorChangeTime = modifiedTime;
}
else {
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
Expand Down Expand Up @@ -1346,56 +1347,54 @@ namespace ts {
}

function getUpToDateStatusWorker(state: SolutionBuilderState, project: ParsedCommandLine, resolvedPath: ResolvedConfigFilePath): UpToDateStatus {
// Container if no files are specified in the project
if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
return {
type: UpToDateStatusType.ContainerOnly
};
}

const force = !!state.options.force;
let newestInputFileName: string = undefined!;
let newestInputFileTime = minimumDate;
const { host } = state;
// Get timestamps of input files
for (const inputFile of project.fileNames) {
if (!host.fileExists(inputFile)) {
const inputTime = getModifiedTime(host, inputFile);
if (inputTime === missingFileModifiedTime) {
return {
type: UpToDateStatusType.Unbuildable,
reason: `${inputFile} does not exist`
};
}

if (!force) {
const inputTime = getModifiedTime(host, inputFile);
if (inputTime > newestInputFileTime) {
newestInputFileName = inputFile;
newestInputFileTime = inputTime;
}
}
}

// Container if no files are specified in the project
if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
return {
type: UpToDateStatusType.ContainerOnly
};
}

// Collect the expected outputs of this project
const outputs = getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());

// Now see if all outputs are newer than the newest input
let oldestOutputFileName = "(none)";
let oldestOutputFileTime = maximumDate;
let newestOutputFileName = "(none)";
let newestOutputFileTime = minimumDate;
let missingOutputFileName: string | undefined;
let newestDeclarationFileContentChangedTime = minimumDate;
let isOutOfDateWithInputs = false;
if (!force) {
for (const output of outputs) {
// Output is missing; can stop checking
// Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
if (!host.fileExists(output)) {
const outputTime = getModifiedTime(host, output);
if (outputTime === missingFileModifiedTime) {
missingOutputFileName = output;
break;
}

const outputTime = getModifiedTime(host, output);
if (outputTime < oldestOutputFileTime) {
oldestOutputFileTime = outputTime;
oldestOutputFileName = output;
Expand All @@ -1408,11 +1407,6 @@ namespace ts {
break;
}

if (outputTime > newestOutputFileTime) {
newestOutputFileTime = outputTime;
newestOutputFileName = output;
}

// Keep track of when the most recent time a .d.ts file was changed.
// In addition to file timestamps, we also keep track of when a .d.ts file
// had its file touched but not had its contents changed - this allows us
Expand Down Expand Up @@ -1546,9 +1540,7 @@ namespace ts {
type: pseudoUpToDate ? UpToDateStatusType.UpToDateWithUpstreamTypes : UpToDateStatusType.UpToDate,
newestDeclarationFileContentChangedTime,
newestInputFileTime,
newestOutputFileTime,
newestInputFileName,
newestOutputFileName,
oldestOutputFileName
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,19 @@ getModifiedTime:: {
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1
"/src/app/file4.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

setModifiedTime:: {}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 3,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 1,
"/src/app/file1.ts": 1,
"/src/app/file1.tsx": 1,
"/src/app/file1.d.ts": 1,
Expand All @@ -119,7 +116,8 @@ fileExists:: {
"/src/file1.jsx": 1,
"/file1.js": 1,
"/file1.jsx": 1,
"/src/app/module.d.ts": 2
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down Expand Up @@ -1027,19 +1025,10 @@ setModifiedTime:: {
}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/app/module.js.map": 1,
"/src/app/module.d.ts": 2,
"/src/app/module.d.ts.map": 1,
"/src/app/module.tsbuildinfo": 1
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,19 @@ getModifiedTime:: {
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1
"/src/app/file4.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

setModifiedTime:: {}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 3,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 1,
"/src/app/file1.ts": 1,
"/src/app/file1.tsx": 1,
"/src/app/file1.d.ts": 1,
Expand All @@ -131,7 +128,8 @@ fileExists:: {
"/src/file1.jsx": 1,
"/file1.js": 1,
"/file1.jsx": 1,
"/src/app/module.d.ts": 2
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down Expand Up @@ -2204,19 +2202,10 @@ setModifiedTime:: {
}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/app/module.js.map": 1,
"/src/app/module.d.ts": 2,
"/src/app/module.d.ts.map": 1,
"/src/app/module.tsbuildinfo": 1
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down Expand Up @@ -3865,19 +3854,10 @@ setModifiedTime:: {
}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/app/module.js.map": 1,
"/src/app/module.d.ts": 2,
"/src/app/module.d.ts.map": 1,
"/src/app/module.tsbuildinfo": 1
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,19 @@ getModifiedTime:: {
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1
"/src/app/file4.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

setModifiedTime:: {}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 3,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 1,
"/src/app/file1.ts": 1,
"/src/app/file1.tsx": 1,
"/src/app/file1.d.ts": 1,
Expand All @@ -124,7 +121,8 @@ fileExists:: {
"/src/file1.jsx": 1,
"/file1.js": 1,
"/file1.jsx": 1,
"/src/app/module.d.ts": 2
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down Expand Up @@ -1313,19 +1311,10 @@ setModifiedTime:: {
}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/app/module.js.map": 1,
"/src/app/module.d.ts": 2,
"/src/app/module.d.ts.map": 1,
"/src/app/module.tsbuildinfo": 1
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down Expand Up @@ -2245,19 +2234,10 @@ setModifiedTime:: {
}

fileExists:: {
"/src/lib/file0.ts": 1,
"/src/lib/file1.ts": 1,
"/src/lib/file2.ts": 1,
"/src/lib/global.ts": 1,
"/src/lib/module.js": 2,
"/src/lib/module.d.ts": 2,
"/src/app/file3.ts": 1,
"/src/app/file4.ts": 1,
"/src/app/module.js": 2,
"/src/app/module.js.map": 1,
"/src/app/module.d.ts": 2,
"/src/app/module.d.ts.map": 1,
"/src/app/module.tsbuildinfo": 1
"/src/lib/module.js": 1,
"/src/lib/module.d.ts": 1,
"/src/app/module.js": 1,
"/src/app/module.d.ts": 1
}

directoryExists:: {
Expand Down
Loading

0 comments on commit 59ad6ef

Please sign in to comment.