Skip to content

[WIP] Persist resolutions and program information and reuse it when building program incrementally or during editor #41004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
226f3ec
Use hash of source file text as version for the source file
sheetalkamat Mar 2, 2021
bf5e953
Add way to handle different script kind for the source file to determ…
sheetalkamat May 11, 2021
364826d
Let source file store resolutions with failed lookup locations
sheetalkamat Mar 2, 2021
4b306e1
Ensure program uses sourceFile version and Path instead of fileNames …
sheetalkamat Oct 7, 2020
1784730
Add assert that redirectTarget file is already seen before redirect f…
sheetalkamat Oct 8, 2020
430462a
Switch program to store name to ResolvedTypeReferenceDirective
sheetalkamat Oct 8, 2020
02bd384
Some more updates to module resolution reuse
sheetalkamat Oct 8, 2020
830df2e
Its ok to compare the file version for redirect files
sheetalkamat Oct 9, 2020
48abe6c
Make getFilesByName buildinfo ready
sheetalkamat Oct 9, 2020
396ec7f
Create Types for ProgramFromBuildInfo
sheetalkamat Oct 8, 2020
69f5ded
Skeleton for buildinfo program
sheetalkamat Oct 9, 2020
31b7991
Add option persistResolutions
sheetalkamat Oct 12, 2020
f854038
CleanResolutions to remove resolutions from tsbuildinfo file
sheetalkamat Oct 12, 2020
9e07d45
Clean resolutions from tsbuild info
sheetalkamat Oct 12, 2020
6ee1739
Tests
sheetalkamat Oct 12, 2020
65c4930
Handle outFile
sheetalkamat Oct 13, 2020
58b95b9
Emit bundle only if there are sections for bundle
sheetalkamat Mar 19, 2021
070b846
Persist resolutions, persists resolutions in program and not watches …
sheetalkamat Oct 13, 2020
cf12c5e
renames to cleanPersistedProgram
sheetalkamat Oct 15, 2020
cfc5f93
Add tests where resolutions are reused which is much more common scen…
sheetalkamat Oct 21, 2020
d073cd4
Store program to persist in buildinfo and clean it as part of cleanRe…
sheetalkamat Oct 21, 2020
c7dcf3c
Use fileIds for filesByName and missingPaths
sheetalkamat Mar 10, 2021
a75a411
More usage of fileId in source file data
sheetalkamat Mar 10, 2021
ecb0ef9
Handle file processing diagnostics and ResolvedProjectReference sourc…
sheetalkamat Mar 10, 2021
d4c5719
Convert fileName and originalFileName in the sourceFile to fileId
sheetalkamat Mar 19, 2021
63490b4
ProjectReference and ResolvedProjectReference mapping
sheetalkamat Mar 19, 2021
59c8b62
rootFileNames and redirectTargets mapping
sheetalkamat Mar 19, 2021
986cd61
Make `cleanPersistedProgram` option internal
sheetalkamat Mar 4, 2021
5c1598b
Ensure that the diagnostic message keys get converted correctly
sheetalkamat Mar 4, 2021
d847b00
Handle typeref, reference directives and lib directives
sheetalkamat Mar 19, 2021
03ee004
Baseline readable file include reason
sheetalkamat Mar 19, 2021
00005be
Map resolutions
sheetalkamat Mar 20, 2021
a3e7aaa
Refactor
sheetalkamat Mar 22, 2021
9d7cdad
More tests
sheetalkamat Mar 4, 2021
0080cb5
MissingFilePaths are on demand and dont need to be stored
sheetalkamat Mar 4, 2021
f0be476
Tests for tsserver scenario
sheetalkamat Mar 5, 2021
0fc318e
Actually make the tsserver tests with persistResolutions
sheetalkamat Mar 5, 2021
4dbd53f
Refactoring
sheetalkamat Mar 24, 2021
86a3b17
Persist resolutions in services
sheetalkamat Mar 25, 2021
8741321
Add more tests
sheetalkamat Mar 30, 2021
841b9ae
persistResolutions will reuse resolutions only if it is resolved
sheetalkamat Mar 30, 2021
688b635
Some more tests
sheetalkamat May 18, 2021
8ec6dab
Do not watch failed lookup locations in persistResolutions if resolve…
sheetalkamat May 18, 2021
76ec5cd
Add tests for auto type reference directives
sheetalkamat May 18, 2021
4118283
Save names of auto type directive names so that we can update program…
sheetalkamat May 25, 2021
d604d19
Tests for project references and persistResolutions (without actually…
sheetalkamat May 26, 2021
5d658c6
Tests with actual persistResolutions
sheetalkamat Jun 1, 2021
f0db440
Handle the difference is useSourceOfProjectReferenceRedirect and proj…
sheetalkamat Jun 2, 2021
dafa644
Merge branch 'main' into persistentResolutions
sheetalkamat Jun 4, 2021
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
Refactor
  • Loading branch information
sheetalkamat committed Jun 2, 2021
commit a3e7aaa482258d7f490330955791c20cb820aafa
27 changes: 8 additions & 19 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,39 +883,28 @@ namespace ts {
}
/** If key and value are same, just use ProgramBuildInfoFileId otherwise pair of key followed by value */
export type PersistedProgramFileByNameEntry = ProgramBuildInfoFileId | [fileId: ProgramBuildInfoFileId, file: ProgramBuildInfoFileId | typeof missingSourceOfProjectReferenceRedirect | typeof missingFile];
export interface ResolvedModuleWithFailedLookupLocations extends ResolutionWithFailedLookupLocations { }
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations extends ResolutionWithFailedLookupLocations { }
export interface PersistedProgramReferencedFile {
kind: ReferencedFileKind;
export type PersistedProgramReferencedFile = Omit<ReferencedFile, "file"> & {
file: ProgramBuildInfoFileId;
index: number;
}
};
export type PersistedProgramFileIncludeReason =
RootFile |
LibFile |
ProjectReferenceFile |
PersistedProgramReferencedFile |
AutomaticTypeDirectiveFile;
export interface PersistedProgramFilePreprocessingReferencedDiagnostic {
kind: FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic;
export type PersistedProgramFilePreprocessingReferencedDiagnostic = Omit<FilePreprocessingReferencedDiagnostic, "reason" | "diagnostic"> & {
reason: PersistedProgramReferencedFile;
diagnostic: keyof typeof Diagnostics;
args?: (string | number | undefined)[];
}
export interface PersistedProgramFilePreprocessingFileExplainingDiagnostic {
kind: FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic;
};
export type PersistedProgramFilePreprocessingFileExplainingDiagnostic = Omit<FilePreprocessingFileExplainingDiagnostic, "file" | "fileProcessingReason" | "diagnostic"> & {
file?: ProgramBuildInfoFileId;
fileProcessingReason: PersistedProgramFileIncludeReason;
diagnostic: keyof typeof Diagnostics;
args?: (string | number | undefined)[];
}
};
export type PersistedProgramFilePreprocessingDiagnostic = PersistedProgramFilePreprocessingReferencedDiagnostic | PersistedProgramFilePreprocessingFileExplainingDiagnostic;
export interface PersistedProgramProjectReference {
export type PersistedProgramProjectReference = Omit<ProjectReference, "path"> & {
path: ProgramBuildInfoAbsoluteFileId;
originalPath?: string;
prepend?: boolean;
circular?: boolean;
}
};
export interface PersistedProgramResolvedProjectReference {
commandLine: {
fileNames: readonly ProgramBuildInfoAbsoluteFileId[] | undefined;
Expand Down
27 changes: 6 additions & 21 deletions src/testRunner/unittests/tsbuild/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,17 @@ interface Symbol {
}
type ReadablePersistedProgramResolution = ReadablePersistedProgramResolvedModuleWithFailedLookupLocations & ReadablePersistedProgramResolvedTypeReferenceDirectiveWithFailedLookupLocations;
type ReadablePersistedProgramResolutionEntry = [name: string, resolution: ReadablePersistedProgramResolution];
interface ReadablePersistedProgramSourceFile {
type ReadablePersistedProgramSourceFile = Omit<PersistedProgramSourceFile, "fileName" | "originalFileName" | "path" | "resolvedPath" | "resolvedModules" | "resolvedTypeReferenceDirectiveNames" | "redirectInfo" | "includeReasons" | "redirectTargets"> & {
fileName: string;
originalFileName: string;
path: string;
resolvedPath: string;
flags: NodeFlags;
version: string;
typeReferenceDirectives?: readonly string[];
libReferenceDirectives?: readonly string[];
referencedFiles?: readonly string[];
imports?: readonly StringLiteralLikeOfProgramFromBuildInfo[];
moduleAugmentations?: readonly ModuleNameOfProgramFromBuildInfo[];
ambientModuleNames?: readonly string[];
hasNoDefaultLib?: true;
resolvedModules?: readonly ReadablePersistedProgramResolutionEntry[];
resolvedTypeReferenceDirectiveNames?: readonly ReadablePersistedProgramResolutionEntry[];
redirectInfo?: { readonly redirectTarget: { readonly path: string }; };
includeReasons: readonly ReadablePersistedProgramFileIncludeReason[];
isSourceFileFromExternalLibraryPath?: true;
redirectTargets?: readonly string[];
packageName?: string;
}
};
enum ReadableFileIncludeKind {
RootFile = "RootFile",
SourceFromProjectReference = "SourceFromProjectReference",
Expand Down Expand Up @@ -308,19 +297,15 @@ interface Symbol {
FilePreprocessingReferencedDiagnostic = "FilePreprocessingReferencedDiagnostic",
FilePreprocessingFileExplainingDiagnostic = "FilePreprocessingFileExplainingDiagnostic"
}
interface ReadablePersistedProgramFilePreprocessingReferencedDiagnostic {
type ReadablePersistedProgramFilePreprocessingReferencedDiagnostic = Omit<PersistedProgramFilePreprocessingReferencedDiagnostic, "kind" | "reason"> & {
kind: ReadableFilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic;
reason: ReadablePersistedProgramReferencedFile;
diagnostic: keyof typeof Diagnostics;
args?: (string | number | undefined)[];
}
interface ReadablePersistedProgramFilePreprocessingFileExplainingDiagnostic {
};
type ReadablePersistedProgramFilePreprocessingFileExplainingDiagnostic = Omit<PersistedProgramFilePreprocessingFileExplainingDiagnostic, "kind" | "file" | "fileProcessingReason"> & {
kind: ReadableFilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic;
file?: string;
fileProcessingReason: ReadablePersistedProgramFileIncludeReason;
diagnostic: keyof typeof Diagnostics;
args?: (string | number | undefined)[];
}
};
type ReadablePersistedProgramFilePreprocessingDiagnostic = ReadablePersistedProgramFilePreprocessingReferencedDiagnostic | ReadablePersistedProgramFilePreprocessingFileExplainingDiagnostic;
interface ReadablePersistedProgramResolvedProjectReference {
commandLine: {
Expand Down