Skip to content

Commit 59ad6ef

Browse files
committed
Use modified time instead of file existence check
1 parent 0ff8cb3 commit 59ad6ef

File tree

165 files changed

+1774
-3527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+1774
-3527
lines changed

src/compiler/tsbuild.ts

-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ namespace ts {
6868
newestInputFileTime?: Date;
6969
newestInputFileName?: string;
7070
newestDeclarationFileContentChangedTime?: Date;
71-
newestOutputFileTime?: Date;
72-
newestOutputFileName?: string;
7371
oldestOutputFileName: string;
7472
}
7573

src/compiler/tsbuildPublic.ts

+14-22
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,9 @@ namespace ts {
970970
let priorChangeTime: Date | undefined;
971971
if (!anyDtsChanged && isDeclarationFileName(name)) {
972972
// Check for unchanged .d.ts files
973-
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
974-
priorChangeTime = host.getModifiedTime(name);
973+
const modifiedTime = getModifiedTime(host, name);
974+
if (modifiedTime !== missingFileModifiedTime && state.readFileWithCache(name) === text) {
975+
priorChangeTime = modifiedTime;
975976
}
976977
else {
977978
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
@@ -1346,56 +1347,54 @@ namespace ts {
13461347
}
13471348

13481349
function getUpToDateStatusWorker(state: SolutionBuilderState, project: ParsedCommandLine, resolvedPath: ResolvedConfigFilePath): UpToDateStatus {
1350+
// Container if no files are specified in the project
1351+
if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
1352+
return {
1353+
type: UpToDateStatusType.ContainerOnly
1354+
};
1355+
}
1356+
13491357
const force = !!state.options.force;
13501358
let newestInputFileName: string = undefined!;
13511359
let newestInputFileTime = minimumDate;
13521360
const { host } = state;
13531361
// Get timestamps of input files
13541362
for (const inputFile of project.fileNames) {
1355-
if (!host.fileExists(inputFile)) {
1363+
const inputTime = getModifiedTime(host, inputFile);
1364+
if (inputTime === missingFileModifiedTime) {
13561365
return {
13571366
type: UpToDateStatusType.Unbuildable,
13581367
reason: `${inputFile} does not exist`
13591368
};
13601369
}
13611370

13621371
if (!force) {
1363-
const inputTime = getModifiedTime(host, inputFile);
13641372
if (inputTime > newestInputFileTime) {
13651373
newestInputFileName = inputFile;
13661374
newestInputFileTime = inputTime;
13671375
}
13681376
}
13691377
}
13701378

1371-
// Container if no files are specified in the project
1372-
if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
1373-
return {
1374-
type: UpToDateStatusType.ContainerOnly
1375-
};
1376-
}
1377-
13781379
// Collect the expected outputs of this project
13791380
const outputs = getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
13801381

13811382
// Now see if all outputs are newer than the newest input
13821383
let oldestOutputFileName = "(none)";
13831384
let oldestOutputFileTime = maximumDate;
1384-
let newestOutputFileName = "(none)";
1385-
let newestOutputFileTime = minimumDate;
13861385
let missingOutputFileName: string | undefined;
13871386
let newestDeclarationFileContentChangedTime = minimumDate;
13881387
let isOutOfDateWithInputs = false;
13891388
if (!force) {
13901389
for (const output of outputs) {
13911390
// Output is missing; can stop checking
13921391
// Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
1393-
if (!host.fileExists(output)) {
1392+
const outputTime = getModifiedTime(host, output);
1393+
if (outputTime === missingFileModifiedTime) {
13941394
missingOutputFileName = output;
13951395
break;
13961396
}
13971397

1398-
const outputTime = getModifiedTime(host, output);
13991398
if (outputTime < oldestOutputFileTime) {
14001399
oldestOutputFileTime = outputTime;
14011400
oldestOutputFileName = output;
@@ -1408,11 +1407,6 @@ namespace ts {
14081407
break;
14091408
}
14101409

1411-
if (outputTime > newestOutputFileTime) {
1412-
newestOutputFileTime = outputTime;
1413-
newestOutputFileName = output;
1414-
}
1415-
14161410
// Keep track of when the most recent time a .d.ts file was changed.
14171411
// In addition to file timestamps, we also keep track of when a .d.ts file
14181412
// had its file touched but not had its contents changed - this allows us
@@ -1546,9 +1540,7 @@ namespace ts {
15461540
type: pseudoUpToDate ? UpToDateStatusType.UpToDateWithUpstreamTypes : UpToDateStatusType.UpToDate,
15471541
newestDeclarationFileContentChangedTime,
15481542
newestInputFileTime,
1549-
newestOutputFileTime,
15501543
newestInputFileName,
1551-
newestOutputFileName,
15521544
oldestOutputFileName
15531545
};
15541546
}

tests/baselines/reference/tsbuild/amdModulesWithOut/modules-and-globals-mixed-in-amd.js

+13-24
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,19 @@ getModifiedTime:: {
8888
"/src/lib/file1.ts": 1,
8989
"/src/lib/file2.ts": 1,
9090
"/src/lib/global.ts": 1,
91+
"/src/lib/module.js": 1,
92+
"/src/lib/module.d.ts": 1,
9193
"/src/app/file3.ts": 1,
92-
"/src/app/file4.ts": 1
94+
"/src/app/file4.ts": 1,
95+
"/src/app/module.js": 1,
96+
"/src/app/module.d.ts": 1
9397
}
9498

9599
setModifiedTime:: {}
96100

97101
fileExists:: {
98-
"/src/lib/file0.ts": 1,
99-
"/src/lib/file1.ts": 1,
100-
"/src/lib/file2.ts": 1,
101-
"/src/lib/global.ts": 1,
102-
"/src/lib/module.js": 3,
103-
"/src/lib/module.d.ts": 2,
104-
"/src/app/file3.ts": 1,
105-
"/src/app/file4.ts": 1,
106-
"/src/app/module.js": 2,
102+
"/src/lib/module.js": 2,
103+
"/src/lib/module.d.ts": 1,
107104
"/src/app/file1.ts": 1,
108105
"/src/app/file1.tsx": 1,
109106
"/src/app/file1.d.ts": 1,
@@ -119,7 +116,8 @@ fileExists:: {
119116
"/src/file1.jsx": 1,
120117
"/file1.js": 1,
121118
"/file1.jsx": 1,
122-
"/src/app/module.d.ts": 2
119+
"/src/app/module.js": 1,
120+
"/src/app/module.d.ts": 1
123121
}
124122

125123
directoryExists:: {
@@ -1027,19 +1025,10 @@ setModifiedTime:: {
10271025
}
10281026

10291027
fileExists:: {
1030-
"/src/lib/file0.ts": 1,
1031-
"/src/lib/file1.ts": 1,
1032-
"/src/lib/file2.ts": 1,
1033-
"/src/lib/global.ts": 1,
1034-
"/src/lib/module.js": 2,
1035-
"/src/lib/module.d.ts": 2,
1036-
"/src/app/file3.ts": 1,
1037-
"/src/app/file4.ts": 1,
1038-
"/src/app/module.js": 2,
1039-
"/src/app/module.js.map": 1,
1040-
"/src/app/module.d.ts": 2,
1041-
"/src/app/module.d.ts.map": 1,
1042-
"/src/app/module.tsbuildinfo": 1
1028+
"/src/lib/module.js": 1,
1029+
"/src/lib/module.d.ts": 1,
1030+
"/src/app/module.js": 1,
1031+
"/src/app/module.d.ts": 1
10431032
}
10441033

10451034
directoryExists:: {

tests/baselines/reference/tsbuild/amdModulesWithOut/multiple-emitHelpers-in-all-projects.js

+17-37
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,19 @@ getModifiedTime:: {
100100
"/src/lib/file1.ts": 1,
101101
"/src/lib/file2.ts": 1,
102102
"/src/lib/global.ts": 1,
103+
"/src/lib/module.js": 1,
104+
"/src/lib/module.d.ts": 1,
103105
"/src/app/file3.ts": 1,
104-
"/src/app/file4.ts": 1
106+
"/src/app/file4.ts": 1,
107+
"/src/app/module.js": 1,
108+
"/src/app/module.d.ts": 1
105109
}
106110

107111
setModifiedTime:: {}
108112

109113
fileExists:: {
110-
"/src/lib/file0.ts": 1,
111-
"/src/lib/file1.ts": 1,
112-
"/src/lib/file2.ts": 1,
113-
"/src/lib/global.ts": 1,
114-
"/src/lib/module.js": 3,
115-
"/src/lib/module.d.ts": 2,
116-
"/src/app/file3.ts": 1,
117-
"/src/app/file4.ts": 1,
118-
"/src/app/module.js": 2,
114+
"/src/lib/module.js": 2,
115+
"/src/lib/module.d.ts": 1,
119116
"/src/app/file1.ts": 1,
120117
"/src/app/file1.tsx": 1,
121118
"/src/app/file1.d.ts": 1,
@@ -131,7 +128,8 @@ fileExists:: {
131128
"/src/file1.jsx": 1,
132129
"/file1.js": 1,
133130
"/file1.jsx": 1,
134-
"/src/app/module.d.ts": 2
131+
"/src/app/module.js": 1,
132+
"/src/app/module.d.ts": 1
135133
}
136134

137135
directoryExists:: {
@@ -2204,19 +2202,10 @@ setModifiedTime:: {
22042202
}
22052203

22062204
fileExists:: {
2207-
"/src/lib/file0.ts": 1,
2208-
"/src/lib/file1.ts": 1,
2209-
"/src/lib/file2.ts": 1,
2210-
"/src/lib/global.ts": 1,
2211-
"/src/lib/module.js": 2,
2212-
"/src/lib/module.d.ts": 2,
2213-
"/src/app/file3.ts": 1,
2214-
"/src/app/file4.ts": 1,
2215-
"/src/app/module.js": 2,
2216-
"/src/app/module.js.map": 1,
2217-
"/src/app/module.d.ts": 2,
2218-
"/src/app/module.d.ts.map": 1,
2219-
"/src/app/module.tsbuildinfo": 1
2205+
"/src/lib/module.js": 1,
2206+
"/src/lib/module.d.ts": 1,
2207+
"/src/app/module.js": 1,
2208+
"/src/app/module.d.ts": 1
22202209
}
22212210

22222211
directoryExists:: {
@@ -3865,19 +3854,10 @@ setModifiedTime:: {
38653854
}
38663855

38673856
fileExists:: {
3868-
"/src/lib/file0.ts": 1,
3869-
"/src/lib/file1.ts": 1,
3870-
"/src/lib/file2.ts": 1,
3871-
"/src/lib/global.ts": 1,
3872-
"/src/lib/module.js": 2,
3873-
"/src/lib/module.d.ts": 2,
3874-
"/src/app/file3.ts": 1,
3875-
"/src/app/file4.ts": 1,
3876-
"/src/app/module.js": 2,
3877-
"/src/app/module.js.map": 1,
3878-
"/src/app/module.d.ts": 2,
3879-
"/src/app/module.d.ts.map": 1,
3880-
"/src/app/module.tsbuildinfo": 1
3857+
"/src/lib/module.js": 1,
3858+
"/src/lib/module.d.ts": 1,
3859+
"/src/app/module.js": 1,
3860+
"/src/app/module.d.ts": 1
38813861
}
38823862

38833863
directoryExists:: {

tests/baselines/reference/tsbuild/amdModulesWithOut/multiple-prologues-in-all-projects.js

+17-37
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,19 @@ getModifiedTime:: {
9393
"/src/lib/file1.ts": 1,
9494
"/src/lib/file2.ts": 1,
9595
"/src/lib/global.ts": 1,
96+
"/src/lib/module.js": 1,
97+
"/src/lib/module.d.ts": 1,
9698
"/src/app/file3.ts": 1,
97-
"/src/app/file4.ts": 1
99+
"/src/app/file4.ts": 1,
100+
"/src/app/module.js": 1,
101+
"/src/app/module.d.ts": 1
98102
}
99103

100104
setModifiedTime:: {}
101105

102106
fileExists:: {
103-
"/src/lib/file0.ts": 1,
104-
"/src/lib/file1.ts": 1,
105-
"/src/lib/file2.ts": 1,
106-
"/src/lib/global.ts": 1,
107-
"/src/lib/module.js": 3,
108-
"/src/lib/module.d.ts": 2,
109-
"/src/app/file3.ts": 1,
110-
"/src/app/file4.ts": 1,
111-
"/src/app/module.js": 2,
107+
"/src/lib/module.js": 2,
108+
"/src/lib/module.d.ts": 1,
112109
"/src/app/file1.ts": 1,
113110
"/src/app/file1.tsx": 1,
114111
"/src/app/file1.d.ts": 1,
@@ -124,7 +121,8 @@ fileExists:: {
124121
"/src/file1.jsx": 1,
125122
"/file1.js": 1,
126123
"/file1.jsx": 1,
127-
"/src/app/module.d.ts": 2
124+
"/src/app/module.js": 1,
125+
"/src/app/module.d.ts": 1
128126
}
129127

130128
directoryExists:: {
@@ -1313,19 +1311,10 @@ setModifiedTime:: {
13131311
}
13141312

13151313
fileExists:: {
1316-
"/src/lib/file0.ts": 1,
1317-
"/src/lib/file1.ts": 1,
1318-
"/src/lib/file2.ts": 1,
1319-
"/src/lib/global.ts": 1,
1320-
"/src/lib/module.js": 2,
1321-
"/src/lib/module.d.ts": 2,
1322-
"/src/app/file3.ts": 1,
1323-
"/src/app/file4.ts": 1,
1324-
"/src/app/module.js": 2,
1325-
"/src/app/module.js.map": 1,
1326-
"/src/app/module.d.ts": 2,
1327-
"/src/app/module.d.ts.map": 1,
1328-
"/src/app/module.tsbuildinfo": 1
1314+
"/src/lib/module.js": 1,
1315+
"/src/lib/module.d.ts": 1,
1316+
"/src/app/module.js": 1,
1317+
"/src/app/module.d.ts": 1
13291318
}
13301319

13311320
directoryExists:: {
@@ -2245,19 +2234,10 @@ setModifiedTime:: {
22452234
}
22462235

22472236
fileExists:: {
2248-
"/src/lib/file0.ts": 1,
2249-
"/src/lib/file1.ts": 1,
2250-
"/src/lib/file2.ts": 1,
2251-
"/src/lib/global.ts": 1,
2252-
"/src/lib/module.js": 2,
2253-
"/src/lib/module.d.ts": 2,
2254-
"/src/app/file3.ts": 1,
2255-
"/src/app/file4.ts": 1,
2256-
"/src/app/module.js": 2,
2257-
"/src/app/module.js.map": 1,
2258-
"/src/app/module.d.ts": 2,
2259-
"/src/app/module.d.ts.map": 1,
2260-
"/src/app/module.tsbuildinfo": 1
2237+
"/src/lib/module.js": 1,
2238+
"/src/lib/module.d.ts": 1,
2239+
"/src/app/module.js": 1,
2240+
"/src/app/module.d.ts": 1
22612241
}
22622242

22632243
directoryExists:: {

0 commit comments

Comments
 (0)