GeezerVison is showing github.com — Build .tsbuildinfo file when building using tsc --b by sheetalkamat · Pull Request #29813 · microsoft/TypeScript
Conversation
- When tsconfig specifies compiler options
incremental file with .tsbuildinfo extension is emitted.
- Composite projects indirectly specify
incremental as true and its error to specify incremental as false in the composite project
- If project specifies
tsBuildInfoFile options, it uses the path specified by that to write the build information.
- If project specifies
out or outFile option, the outFileWithoutExtension.tsbuildinfo file is written next to output js file.
- If project specified
outDir, config files base file name with extension as .tsbuildinfo is written in outDir
- Otherswise config files base file name with extension as
.tsbuildinfo is written next to the config file
- Generated file is json with type as
BuildInfo shown below.
export interface SourceFileInfo {
// List of helpers in own source files emitted if no prepend is present
helpers?: string[];
prologues?: SourceFilePrologueInfo[];
}
export interface BundleFileInfo {
sections: BundleFileSection[];
sources?: SourceFileInfo;
}
export interface BundleBuildInfo {
js?: BundleFileInfo;
dts?: BundleFileInfo;
commonSourceDirectory: string;
sourceFiles: ReadonlyArray<string>;
}
export interface ProgramBuildInfo {
fileInfos: MapLike<BuilderState.FileInfo>;
options: CompilerOptions;
referencedMap?: MapLike<string[]>;
exportedModulesMap?: MapLike<string[]>;
semanticDiagnosticsPerFile?: string[];
}
export interface BuildInfo {
bundle?: BundleBuildInfo;
program?: ProgramBuildInfo;
version: string;
}
- Field
program in buildInfo is Builder information so we can track the file changes since that version and build incrementally even without watch (that is emitting only affected files or getting errors only from changed/affected files). This should help us get perf similar to --w incremental builds even on subsequent invokes of build (In short we are serializing information of builder program that we keep in memory during incremental builds in --w mode). Also pulled 6c5ae93 to store semantic diagnostics though in --b scenario it will always be just file name as emit happens only if there are no errors.
- Field
bundle stores information to be able to emit into single file. This consists of different sections in file, eg. prologues, prepended file contents and their range's. When having project that references another project with prepend as true, this helps in faster emit when the referenced project changes but it doesn't change declaration file. Previously we would have to create program for project referencing changed output to generate new output, but this just uses section information from buildinfo file and emit new output without having to create program. This saves us time for creating program and checking errors (since the errors are not cached with --out as we cant tell change in declaration emit) and emitting all files. Having section also fixes issues like Duplicate "use strict" prologue in the generated output. #25550 to generate better output.
- if version of compiler does not match with version in the buildInfo file, it starts fresh build
- The bundle information also contains
internal declaration sections, so if project has stripInternal instead of concatenating whole string it skips out portions of internal and generates correct .d.ts
- Currently the build info is generated and emitted in emitter but the information comes from two places, emitter itself (about --out) and the other from the program itself which is actually builder program (so one level of abstraction outside of the program). Open to suggestion if there is different way to write this information. Goal was to not write files multiple time (eg once by builder and once by emitter). Also another thought is that builder doesn't do anything or change much if the scenario is
--out since any change means new emit and new diagnostics, so its ok to not store program information in this case and in other scenario there is nothing of importance in those other section than program so may be separating these two (reading and writing only modified field) might not be a bad decision. But will need to see how that goes.
Measured perf with updating LKG from master to build this branch using gulp local and then with this branch's build as LKG and using gulp local
| Build |
With Master |
With this branch |
| After clean |
Finished 'local' after 52 s |
Finished 'local' after 36 s |
| Local change without --d change |
Finished 'local' after 44 s |
Finished 'local' after 25 s |
| Local change revert |
Finished 'local' after 44 s |
Finished 'local' after 21 s |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
RyanCavanaugh, DanielRosenwasser, timocov, mihailik, maxmilton, and sdwvit reacted with hooray emoji
DanielRosenwasser, BoruiGu, timocov, mihailik, bradleyayers, and sdwvit reacted with heart emoji
DanielRosenwasser, BoruiGu, timocov, mihailik, sdwvit, anri-asaturov, and c69 reacted with rocket emoji
All reactions
-
🎉
6 reactions
-
❤️
6 reactions
-
🚀
7 reactions
…st manipulate output
Step 1: Update the verbose log to reflect it
|
|
if (declarationMapText === text) return;
|
|
|
break;
|
|
|
default:
|
|
|
Debug.assertNever(name as never);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asserting to never here defeats the purpose of the assertNever function
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. this should just be Debug.fail
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…riteFile of SolutionBuilderHost
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Should we commit .tsbuildinfo files to version control?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sdwvit and tommedema reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tommedema reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- If project specified
outDir, config files base file name with extension as .tsbuildinfo is written in outDir
- Otherswise config files base file name with extension as
.tsbuildinfo is written next to the config file
This isn't the behaviour I'm seeing using 3.4.2, it's falling through to the last path option for the build info file. I'm working on a composite project in a yarn workspace, with a config that begins with
{
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"composite": true,
"baseUrl": "."
}
}
When using tsc -b it's generating the tsconfig.tsbuildinfo file next to the config file instead of in the lib folder. I have to specify "tsBuildInfoFile": "lib/tsconfig.tsbuildinfo" manually.
Should I log a new issue for this? It seems easy to repro but I can work on one if needed.
|
intelliot reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|