Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
a3b5207
Use fixed time for vfs so baselining is consistent
sheetalkamat Apr 13, 2022
c20613f
Baseline buildinfos
sheetalkamat Apr 13, 2022
c79af2c
Write new file text in baseline even if the file wasnt read on the sh…
sheetalkamat Apr 14, 2022
40a8c7f
Remove unnecessary debugger statement
sheetalkamat Apr 15, 2022
7377470
Make sure that incremental correctness is checked with correct writeF…
sheetalkamat Apr 15, 2022
c206ff0
More baselines for the tsbuildinfo
sheetalkamat Apr 19, 2022
fc91aff
If we are writing dts file and have used file text as version, we can…
sheetalkamat Apr 13, 2022
396e6c8
Make WriteFileCallback Api ready for future
sheetalkamat Apr 14, 2022
7084221
Assert that there is only single source file when emitting d.ts file
sheetalkamat Apr 15, 2022
5f02cf3
Add test
sheetalkamat Apr 5, 2022
c984298
Renames
sheetalkamat Apr 6, 2022
e4bf58a
More refactoring
sheetalkamat Apr 6, 2022
87a7112
If we are updating dts of any of the file and it affects global scope…
sheetalkamat Apr 6, 2022
16cef4a
Stacktrace optimization for getModified time in anticipation of using…
sheetalkamat Mar 16, 2022
7e65cd3
Baseline getModifiedTime, setModifiedTime, fileExits and directoryExi…
sheetalkamat Apr 5, 2022
0ff8cb3
Remove unnecessary write file finger print code since its not used at…
sheetalkamat Mar 16, 2022
59ad6ef
Use modified time instead of file existence check
sheetalkamat Apr 11, 2022
c8327da
Remove unnecessary getModifiedTime
sheetalkamat Mar 17, 2022
7817fbf
No need to check for file existence before reading the d.ts file
sheetalkamat Mar 17, 2022
cb7aca3
Do project reference errors before doing input/output file checks
sheetalkamat Mar 21, 2022
dd96e33
Dont call getModifiedTimes if dts change
sheetalkamat Mar 28, 2022
89d2d4c
Passdown modified time if queried
sheetalkamat Mar 15, 2022
6e0c916
Use modified time passed through the file watching in tsbuild
sheetalkamat Mar 18, 2022
e6a3ee8
Handle force build as separate upto date status
sheetalkamat Mar 29, 2022
7cb0f40
uptodate status worker to read buildinfo and use it to determine upto…
sheetalkamat Apr 7, 2022
1a8abac
No need to update output timestamps if buildinfo will determine uptod…
sheetalkamat Apr 11, 2022
59f2b5c
Store change file set instead of hasPendingChange to be able to reuse…
sheetalkamat Apr 5, 2022
5c12067
Add test that shows input file is not present
sheetalkamat Apr 7, 2022
7734528
No need to check input time stamp before buildinfo
sheetalkamat Apr 7, 2022
6198fa3
Keep buildinfos for lifetime of the solution builder and project
sheetalkamat Apr 8, 2022
fcf07f8
Store modified time along with text of buildinfo
sheetalkamat Apr 8, 2022
2f2e370
Non composite projects dont need to track declaration change time
sheetalkamat Apr 12, 2022
15fe24e
Pass through buildInfo so we dont have to parse it back
sheetalkamat Apr 14, 2022
dc21283
Save dts change time in buildinfo itself
sheetalkamat Apr 12, 2022
5bccee8
Store dts time for --out in the buildInfo
sheetalkamat Apr 15, 2022
62c687b
Store hash of text in the bundle info so it can be verified before ma…
sheetalkamat Apr 19, 2022
128008a
Since buildinfo is cached no need to maintain version check state
sheetalkamat Apr 19, 2022
4fb6773
Store output time stamps for non incremental builds
sheetalkamat Apr 19, 2022
7e1e9d7
Revert "Baseline getModifiedTime, setModifiedTime, fileExits and dire…
sheetalkamat Apr 5, 2022
cb73874
Change verbose messages for upto date status
sheetalkamat Apr 19, 2022
d8d8609
Merge branch 'main' into timestamps
sheetalkamat Apr 20, 2022
0f7903d
Reconcile reusable builder state and builder state so there are not t…
sheetalkamat Apr 20, 2022
82fb56b
Cleanup impliedFormat
sheetalkamat Apr 20, 2022
7785a87
Cleanup
sheetalkamat Apr 20, 2022
a95d3cc
Cleanup noEmit option
sheetalkamat Apr 20, 2022
437619e
BuildInfo options emit as a flag
sheetalkamat Apr 20, 2022
b568d7e
Factor out types for program written in buildinfo with and without bu…
sheetalkamat Apr 20, 2022
78ba778
No need to store output file stamps if not in watch mode
sheetalkamat Apr 20, 2022
10728b4
Cleanup
sheetalkamat Apr 20, 2022
5492949
Test for single watch per file
sheetalkamat Apr 20, 2022
70069d2
Fix emit and error update baselines that were duplicate
sheetalkamat Apr 21, 2022
21a6806
More refactoring
sheetalkamat Apr 21, 2022
b32d2eb
Only copy emit state fields when backing up to restore if emit fails
sheetalkamat Apr 21, 2022
26e7cb6
Merge branch 'main' into timestamps
sheetalkamat Apr 22, 2022
303824e
Instead of maintaining delta of changes, maintain old state for those…
sheetalkamat Apr 26, 2022
643576c
Merge branch 'main' into timestamps
sheetalkamat Apr 27, 2022
7810c56
Add test to verify build when input file does not change
sheetalkamat Apr 29, 2022
28a9ff3
If version of the input file does not change, dont mark as out of date
sheetalkamat Apr 29, 2022
929ddad
Merge branch 'main' into timestamps
sheetalkamat Apr 29, 2022
5d31847
Disable lint warning as build fails without the assert
sheetalkamat Apr 29, 2022
fa1068e
Merge branch 'main' into timestamps
sheetalkamat May 6, 2022
94e7e43
Merge branch 'main' into timestamps
sheetalkamat May 24, 2022
7593eee
Merge branch 'main' into timestamps
sheetalkamat May 27, 2022
405d8e9
Report aggregate statistics for solution as well as some solution per…
sheetalkamat May 27, 2022
fe69264
Merge branch 'main' into timestamps
sheetalkamat Jun 1, 2022
0cf9e30
Options solutionDiagnostics instead so that its not too verbose when …
sheetalkamat Jun 1, 2022
e4e6672
When tsc --build --clean, only remove tsbuildinfo if its incremental …
sheetalkamat Jun 2, 2022
842de49
Merge branch 'main' into timestamps
sheetalkamat Jun 6, 2022
5c07c77
Revert "Options solutionDiagnostics instead so that its not too verbo…
sheetalkamat Jun 7, 2022
31427f6
Revert "Report aggregate statistics for solution as well as some solu…
sheetalkamat Jun 7, 2022
0f898f2
Merge branch 'main' into timestamps
sheetalkamat Jun 7, 2022
5cd883a
Revert "When tsc --build --clean, only remove tsbuildinfo if its incr…
sheetalkamat Jun 7, 2022
5cd5d57
Comments in the code
sheetalkamat Jun 7, 2022
624c182
Feedback
sheetalkamat Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Store output time stamps for non incremental builds
  • Loading branch information
sheetalkamat committed Apr 19, 2022
commit 4fb6773b78ca63ea289019056bab41f7accb9132
51 changes: 40 additions & 11 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ namespace ts {
readonly projectStatus: ESMap<ResolvedConfigFilePath, UpToDateStatus>;
readonly extendedConfigCache: ESMap<string, ExtendedConfigCacheEntry>;
readonly buildInfoCache: ESMap<ResolvedConfigFilePath, BuildInfoCacheEntry>;
readonly outputTimeStamps: ESMap<ResolvedConfigFilePath, ESMap<Path, Date>>;

readonly builderPrograms: ESMap<ResolvedConfigFilePath, T>;
readonly diagnostics: ESMap<ResolvedConfigFilePath, readonly Diagnostic[]>;
Expand Down Expand Up @@ -330,6 +331,7 @@ namespace ts {
projectStatus: new Map(),
extendedConfigCache: new Map(),
buildInfoCache: new Map(),
outputTimeStamps: new Map(),

builderPrograms: new Map(),
diagnostics: new Map(),
Expand Down Expand Up @@ -493,6 +495,7 @@ namespace ts {
mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);

// Remove watches for the program no longer in the solution
if (state.watch) {
Expand Down Expand Up @@ -983,15 +986,23 @@ namespace ts {
const existingBuildInfo = state.buildInfoCache.get(projectPath)?.buildInfo || undefined;
const emitterDiagnostics = createDiagnosticCollection();
const emittedOutputs = new Map<Path, string>();
const options = program.getCompilerOptions();
const isIncremental = isIncrementalCompilation(options);
let outputTimeStampMap: ESMap<Path, Date> | undefined;
let now: Date | undefined;
outputFiles.forEach(({ name, text, writeByteOrderMark, buildInfo }) => {
Comment thread
sheetalkamat marked this conversation as resolved.
const path = toPath(state, name);
emittedOutputs.set(toPath(state, name), name);
if (buildInfo) {
setBuildInfo(state, buildInfo, projectPath, program!.getCompilerOptions());
setBuildInfo(state, buildInfo, projectPath, options);
if (buildInfo.program?.dtsChangeTime !== existingBuildInfo?.program?.dtsChangeTime) {
resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
}
}
writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
if (!isIncremental) {
(outputTimeStampMap ||= getOutputTimeStampMap(state, projectPath)).set(path, now ||= getCurrentTime(state.host));
Comment thread
sheetalkamat marked this conversation as resolved.
Outdated
}
});

finishEmit(
Expand Down Expand Up @@ -1050,7 +1061,7 @@ namespace ts {
}

// Update time stamps for rest of the outputs
updateOutputTimestampsWorker(state, config, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
updateOutputTimestampsWorker(state, config, projectPath, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
state.diagnostics.delete(projectPath);
state.projectStatus.set(projectPath, {
type: UpToDateStatusType.UpToDate,
Expand Down Expand Up @@ -1402,6 +1413,12 @@ namespace ts {
};
}

function getOutputTimeStampMap(state: SolutionBuilderState, resolvedConfigFilePath: ResolvedConfigFilePath) {
let result = state.outputTimeStamps.get(resolvedConfigFilePath);
if (!result) state.outputTimeStamps.set(resolvedConfigFilePath, result = new Map());
return result;
}

function setBuildInfo(state: SolutionBuilderState, buildInfo: BuildInfo, resolvedConfigPath: ResolvedConfigFilePath, options: CompilerOptions) {
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(options)!;
const existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath);
Expand Down Expand Up @@ -1573,9 +1590,12 @@ namespace ts {
if (!buildInfoPath) {
// Collect the expected outputs of this project
const outputs = getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
Comment thread
sheetalkamat marked this conversation as resolved.
const outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath);
for (const output of outputs) {
const path = toPath(state, output);
// Output is missing; can stop checking
const outputTime = ts.getModifiedTime(state.host, output);
let outputTime = outputTimeStampMap.get(path);
if (!outputTime) outputTimeStampMap.set(path, outputTime = ts.getModifiedTime(state.host, output));
if (outputTime === missingFileModifiedTime) {
return {
type: UpToDateStatusType.OutputMissing,
Expand Down Expand Up @@ -1711,37 +1731,46 @@ namespace ts {
function updateOutputTimestampsWorker(
state: SolutionBuilderState,
proj: ParsedCommandLine,
projectPath: ResolvedConfigFilePath,
verboseMessage: DiagnosticMessage,
skipOutputs?: ESMap<Path, string>
) {
if (proj.options.noEmit) return;
let now: Date | undefined;
const buildInfoPath = getTsBuildInfoEmitOutputFilePath(proj.options);
if (buildInfoPath) {
Comment thread
sheetalkamat marked this conversation as resolved.
if (!skipOutputs?.has(toPath(state, buildInfoPath))) {
if (!!state.options.verbose) reportStatus(state, verboseMessage, proj.options.configFilePath!);
state.host.setModifiedTime(buildInfoPath, getCurrentTime(state.host));
state.host.setModifiedTime(buildInfoPath, now = getCurrentTime(state.host));
getBuildInfoCacheEntry(state, buildInfoPath, projectPath)!.modifiedTime = now;
}
state.outputTimeStamps.delete(projectPath);
return;
}

const { host } = state;
const outputs = getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
const outputTimeStampMap = getOutputTimeStampMap(state, projectPath);
const modifiedOutputs = new Set<Path>();
if (!skipOutputs || outputs.length !== skipOutputs.size) {
let reportVerbose = !!state.options.verbose;
let now: Date | undefined;
for (const file of outputs) {
if (skipOutputs && skipOutputs.has(toPath(state, file))) {
continue;
}

const path = toPath(state, file);
if (skipOutputs?.has(path)) continue;
if (reportVerbose) {
reportVerbose = false;
reportStatus(state, verboseMessage, proj.options.configFilePath!);
}

host.setModifiedTime(file, now ||= getCurrentTime(state.host));
outputTimeStampMap.set(path, now);
modifiedOutputs.add(path);
}
}

// Clear out timestamps not in output list any more
outputTimeStampMap.forEach((_value, key) => {
if (!skipOutputs?.has(key) && !modifiedOutputs.has(key)) outputTimeStampMap.delete(key);
});
}

function getDtsChangeTime(state: SolutionBuilderState, options: CompilerOptions, resolvedConfigPath: ResolvedConfigFilePath) {
Expand All @@ -1755,7 +1784,7 @@ namespace ts {
if (state.options.dry) {
return reportStatus(state, Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath!);
}
updateOutputTimestampsWorker(state, proj, Diagnostics.Updating_output_timestamps_of_project_0);
updateOutputTimestampsWorker(state, proj, resolvedPath, Diagnostics.Updating_output_timestamps_of_project_0);
state.projectStatus.set(resolvedPath, {
type: UpToDateStatusType.UpToDate,
newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,24 +821,24 @@ console.log(s);console.log(s);

Output::
/lib/tsc --b /src/third --verbose --incremental
[12:01:04 AM] Projects in this build:
[12:01:05 AM] Projects in this build:
* src/first/tsconfig.json
* src/second/tsconfig.json
* src/third/tsconfig.json

[12:01:05 AM] Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.tsbuildinfo' is older than newest input 'src/first/first_PART1.ts'
[12:01:06 AM] Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.tsbuildinfo' is older than newest input 'src/first/first_PART1.ts'

[12:01:06 AM] Building project '/src/first/tsconfig.json'...
[12:01:07 AM] Building project '/src/first/tsconfig.json'...

[12:01:15 AM] Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.tsbuildinfo'
[12:01:16 AM] Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.tsbuildinfo'

[12:01:16 AM] Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed
[12:01:17 AM] Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed

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

[12:01:18 AM] Cannot update output of project '/src/third/tsconfig.json' because there was error reading file 'src/third/thirdjs/output/third-output.js'
[12:01:19 AM] Cannot update output of project '/src/third/tsconfig.json' because there was error reading file 'src/third/thirdjs/output/third-output.js'

[12:01:19 AM] Building project '/src/third/tsconfig.json'...
[12:01:20 AM] Building project '/src/third/tsconfig.json'...

exitCode:: ExitStatus.Success

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1774,20 +1774,20 @@ console.log(s);

Output::
/lib/tsc --b /src/third --verbose
[12:00:47 AM] Projects in this build:
[12:00:48 AM] Projects in this build:
* src/first/tsconfig.json
* src/second/tsconfig.json
* src/third/tsconfig.json

[12:00:48 AM] Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.tsbuildinfo' is older than newest input 'src/first/first_PART1.ts'
[12:00:49 AM] Project 'src/first/tsconfig.json' is out of date because oldest output 'src/first/bin/first-output.tsbuildinfo' is older than newest input 'src/first/first_PART1.ts'

[12:00:49 AM] Building project '/src/first/tsconfig.json'...
[12:00:50 AM] Building project '/src/first/tsconfig.json'...

[12:00:58 AM] Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.tsbuildinfo'
[12:00:59 AM] Project 'src/second/tsconfig.json' is up to date because newest input 'src/second/second_part1.ts' is older than oldest output 'src/2/second-output.tsbuildinfo'

[12:00:59 AM] Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed
[12:01:00 AM] Project 'src/third/tsconfig.json' is out of date because output of its dependency 'src/first' has changed

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

exitCode:: ExitStatus.Success

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ Input::

Output::
/lib/tsc --b /src/tsconfig.json -v
[12:00:14 AM] Projects in this build:
[12:00:15 AM] Projects in this build:
* src/tsconfig.json

[12:00:15 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than oldest output 'src/dist/index.js'
[12:00:16 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than oldest output 'src/dist/index.js'

exitCode:: ExitStatus.Success

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ Input::

Output::
/lib/tsc --b /src/tsconfig.json -v
[12:00:14 AM] Projects in this build:
[12:00:15 AM] Projects in this build:
* src/tsconfig.json

[12:00:15 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than oldest output 'src/dist/index.js'
[12:00:16 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than oldest output 'src/dist/index.js'

exitCode:: ExitStatus.Success

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not e
File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist.
File '/user/username/projects/myproject/packages/pkg2/build/const.d.ts' exist - use it as a name resolution result.
======== Module name './const.js' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.ts'. ========
[12:01:15 AM] Found 0 errors. Watching for file changes.
[12:01:16 AM] Found 0 errors. Watching for file changes.



Expand Down Expand Up @@ -349,11 +349,11 @@ setModifiedTimes:: {}

Output::
>> Screen clear
[12:01:19 AM] File change detected. Starting incremental compilation...
[12:01:20 AM] File change detected. Starting incremental compilation...

[12:01:20 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2/package.json'
[12:01:21 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2/package.json'

[12:01:21 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
[12:01:22 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...

======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Expand Down Expand Up @@ -385,7 +385,7 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui
1 import type { TheNum } from 'pkg2'
   ~~~~~~

[12:01:22 AM] Found 1 error. Watching for file changes.
[12:01:23 AM] Found 1 error. Watching for file changes.



Expand Down Expand Up @@ -463,7 +463,6 @@ directoryExists:: {
}

getModifiedTimes:: {
"/user/username/projects/myproject/packages/pkg1/build/index.js": 1,
"/user/username/projects/myproject/packages/pkg1/tsconfig.json": 1
}

Expand All @@ -486,11 +485,11 @@ setModifiedTimes:: {}

Output::
>> Screen clear
[12:01:26 AM] File change detected. Starting incremental compilation...
[12:01:27 AM] File change detected. Starting incremental compilation...

[12:01:27 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2/package.json'
[12:01:28 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2/package.json'

[12:01:28 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...
[12:01:29 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'...

======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Expand Down Expand Up @@ -529,7 +528,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not e
File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist.
File '/user/username/projects/myproject/packages/pkg2/build/const.d.ts' exist - use it as a name resolution result.
======== Module name './const.js' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.ts'. ========
[12:01:32 AM] Found 0 errors. Watching for file changes.
[12:01:34 AM] Found 0 errors. Watching for file changes.



Expand Down Expand Up @@ -617,8 +616,6 @@ directoryExists:: {
"/node_modules/@types": 1
}

getModifiedTimes:: {
"/user/username/projects/myproject/packages/pkg1/build/index.js": 1
}
getModifiedTimes:: {}

setModifiedTimes:: {}
Loading