Skip to content

Commit

Permalink
No need to update output timestamps if buildinfo will determine uptod…
Browse files Browse the repository at this point in the history
…ateness
  • Loading branch information
sheetalkamat committed Apr 19, 2022
1 parent 7cb0f40 commit 1a8abac
Show file tree
Hide file tree
Showing 63 changed files with 466 additions and 1,037 deletions.
18 changes: 11 additions & 7 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1660,26 +1660,30 @@ namespace ts {

function updateOutputTimestampsWorker(state: SolutionBuilderState, proj: ParsedCommandLine, anyDtsChange: boolean, verboseMessage: DiagnosticMessage, newestDeclarationFileContentChangedTime?: Date, skipOutputs?: ESMap<Path, string>) {
if (proj.options.noEmit) return undefined;

const buildInfoPath = getTsBuildInfoEmitOutputFilePath(proj.options);
const { host } = state;
const outputs = getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
if (!skipOutputs || outputs.length !== skipOutputs.size) {
let reportVerbose = !!state.options.verbose;
const now = host.now ? host.now() : new Date();
let now: Date | undefined;
for (const file of outputs) {
if (skipOutputs && skipOutputs.has(toPath(state, file))) {
continue;
}

if (reportVerbose) {
reportVerbose = false;
reportStatus(state, verboseMessage, proj.options.configFilePath!);
}

if (!anyDtsChange && isDeclarationFileName(file)) {
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, ts.getModifiedTime(host, file));
}

host.setModifiedTime(file, now);
if (!buildInfoPath || file === buildInfoPath) {
if (reportVerbose) {
reportVerbose = false;
reportStatus(state, verboseMessage, proj.options.configFilePath!);
}

host.setModifiedTime(file, now ||= host.now ? host.now() : new Date());
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/testRunner/unittests/tsbuild/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ export class someClass { }`),
subScenario: "incremental-declaration-doesnt-change",
modifyFs: fs => appendText(fs, "/src/core/index.ts", `
class someClass2 { }`),
}
},
noChangeRun,
];

describe("lists files", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,6 @@ Output::

[12:00:41 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:46 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -1014,10 +1012,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -1033,8 +1028,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
var myGlob = 20;
define("file1", ["require", "exports"], function (require, exports) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2173,8 +2173,6 @@ Output::

[12:00:47 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:52 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -2191,10 +2189,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -2210,8 +2205,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
Expand Down Expand Up @@ -3810,19 +3803,17 @@ export const x = 10;function forlibfile1Rest() { }console.log(x);

Output::
/lib/tsc --b /src/app --verbose
[[90m12:01:01 AM[0m] Projects in this build:
[[90m12:00:57 AM[0m] Projects in this build:
* src/lib/tsconfig.json
* src/app/tsconfig.json

[[90m12:01:02 AM[0m] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'
[[90m12:00:58 AM[0m] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'

[[90m12:01:03 AM[0m] Building project '/src/lib/tsconfig.json'...
[[90m12:00:59 AM[0m] Building project '/src/lib/tsconfig.json'...

[[90m12:01:11 AM[0m] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed
[[90m12:01:07 AM[0m] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed

[12:01:12 AM] Updating output of project '/src/app/tsconfig.json'...

[12:01:17 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...
[12:01:08 AM] Updating output of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

Expand All @@ -3840,10 +3831,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -3859,8 +3847,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,6 @@ Output::

[12:00:48 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:53 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -1300,10 +1298,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -1319,8 +1314,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
"use strict";
"myPrologue";
Expand Down Expand Up @@ -2191,19 +2184,17 @@ export const x = 10;console.log(x);

Output::
/lib/tsc --b /src/app --verbose
[[90m12:01:02 AM[0m] Projects in this build:
[[90m12:00:58 AM[0m] Projects in this build:
* src/lib/tsconfig.json
* src/app/tsconfig.json

[12:01:03 AM] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'

[12:01:04 AM] Building project '/src/lib/tsconfig.json'...
[12:00:59 AM] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'

[[90m12:01:12 AM[0m] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed
[[90m12:01:00 AM[0m] Building project '/src/lib/tsconfig.json'...

[[90m12:01:13 AM[0m] Updating output of project '/src/app/tsconfig.json'...
[[90m12:01:08 AM[0m] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed

[[90m12:01:19 AM[0m] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...
[[90m12:01:09 AM[0m] Updating output of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

Expand All @@ -2221,9 +2212,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -2239,7 +2228,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map]
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../lib/file0.ts","../lib/file1.ts","../lib/file2.ts","../lib/global.ts","file3.ts","file4.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM,KAAK,CAAC;;ICAlB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;;ICApB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,WAAW,KAAK,CAAC;;ICAvB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;;ACApB,QAAA,MAAM,KAAK,KAAK,CAAC"}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,6 @@ Output::

[12:00:44 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:49 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -1036,10 +1034,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -1055,8 +1050,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
#!someshebang lib file0
var myGlob = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4923,8 +4923,6 @@ Output::

[12:00:44 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:49 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -4941,10 +4939,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -4960,8 +4955,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
/*@internal*/ var myGlob = 20;
define("file1", ["require", "exports"], function (require, exports) {
Expand Down Expand Up @@ -8751,17 +8744,17 @@ export namespace normalN {

Output::
/lib/tsc --b /src/app --verbose
[12:00:58 AM] Projects in this build:
[12:00:54 AM] Projects in this build:
* src/lib/tsconfig.json
* src/app/tsconfig.json

[12:00:59 AM] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'
[12:00:55 AM] Project 'src/lib/tsconfig.json' is out of date because oldest output 'src/lib/module.tsbuildinfo' is older than newest input 'src/lib/file1.ts'

[12:01:00 AM] Building project '/src/lib/tsconfig.json'...
[12:00:56 AM] Building project '/src/lib/tsconfig.json'...

[12:01:08 AM] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed
[12:01:04 AM] Project 'src/app/tsconfig.json' is out of date because output of its dependency 'src/lib' has changed

[12:01:09 AM] Updating output of project '/src/app/tsconfig.json'...
[12:01:05 AM] Updating output of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,6 @@ Output::

[12:00:45 AM] Updating output of project '/src/app/tsconfig.json'...

[12:00:50 AM] Updating unchanged output timestamps of project '/src/app/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -1253,10 +1251,7 @@ getModifiedTime:: {
"/src/app/module.d.ts": 1
}

setModifiedTime:: {
"/src/app/module.d.ts": 1,
"/src/app/module.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/lib/module.js": 1,
Expand All @@ -1272,8 +1267,6 @@ directoryExists:: {
}


//// [/src/app/module.d.ts] file changed its modified time
//// [/src/app/module.d.ts.map] file changed its modified time
//// [/src/app/module.js]
///<reference path="./tripleRef.d.ts"/>
var file0Const = new libfile0();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ Output::

[12:00:23 AM] Building project '/src/tsconfig.json'...

[12:00:28 AM] Updating unchanged output timestamps of project '/src/tsconfig.json'...

exitCode:: ExitStatus.Success

getModifiedTime:: {
Expand All @@ -243,12 +241,7 @@ getModifiedTime:: {
"/src/lib/c.d.ts": 1
}

setModifiedTime:: {
"/src/lib/b.d.ts": 1,
"/src/lib/b.d.ts.map": 1,
"/src/lib/c.d.ts": 1,
"/src/lib/c.d.ts.map": 1
}
setModifiedTime:: {}

fileExists:: {
"/src/src/c.ts": 1,
Expand All @@ -266,7 +259,6 @@ directoryExists:: {
//// [/src/lib/a.d.ts.map]
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../src/a.ts"],"names":[],"mappings":"AAAA,qBAAa,CAAC;IAAG,IAAI,SAAW;CAAE;AAGlC,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;CACN"}

//// [/src/lib/b.d.ts] file changed its modified time
//// [/src/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"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; };","affectsGlobalScope":true},{"version":"6651905050-export class B { prop = \"hello\"; }\n\nclass C { }\nexport interface A {\n b: B;\n}\n","signature":"-4181862109-export declare class B {\r\n prop: string;\r\n}\r\nexport interface A {\r\n b: B;\r\n}\r\n"},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"}

Expand Down Expand Up @@ -363,12 +355,12 @@ export interface A {

Output::
/lib/tsc --b /src --verbose
[12:00:35 AM] Projects in this build:
[12:00:29 AM] Projects in this build:
* src/tsconfig.json

[12:00:36 AM] Project 'src/tsconfig.json' is out of date because oldest output 'src/tsconfig.tsbuildinfo' is older than newest input 'src/src/a.ts'
[12:00:30 AM] Project 'src/tsconfig.json' is out of date because oldest output 'src/tsconfig.tsbuildinfo' is older than newest input 'src/src/a.ts'

[12:00:37 AM] Building project '/src/tsconfig.json'...
[12:00:31 AM] Building project '/src/tsconfig.json'...

exitCode:: ExitStatus.Success

Expand Down
Loading

0 comments on commit 1a8abac

Please sign in to comment.