Skip to content

Commit 4fe8f90

Browse files
committed
Reuse module resolutions in project references
1 parent ecba000 commit 4fe8f90

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/compiler/program.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,9 @@ namespace ts {
11831183
function doesStructuralPermitResolutionsReuse(): boolean {
11841184
switch (structuralIsReused) {
11851185
case StructureIsReused.Not: return false;
1186+
case StructureIsReused.SafeProjectReferenceModules:
1187+
return file.resolvedModules !== undefined &&
1188+
isSourceOfProjectReferenceRedirect(file.originalFileName);
11861189
case StructureIsReused.SafeModules: return true;
11871190
case StructureIsReused.Completely: return true;
11881191

@@ -1255,7 +1258,10 @@ namespace ts {
12551258

12561259
function tryReuseStructureFromOldProgram(): StructureIsReused {
12571260
if (!oldProgram) {
1258-
return StructureIsReused.Not;
1261+
// During initial program creation, root files may import files from project
1262+
// references that were previously loaded. Those resolutions are safe to reuse
1263+
// since another program instance kept them up to date.
1264+
return StructureIsReused.SafeProjectReferenceModules;
12591265
}
12601266

12611267
// check properties that can affect structure of the program or module resolution strategy

src/compiler/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,9 +3824,10 @@ namespace ts {
38243824
/* @internal */
38253825
/** "Structure" refers to the SourceFile graph of a Program linked by module resolutions. */
38263826
export const enum StructureIsReused {
3827-
Not = 0, // The entire Program must be (re)created.
3828-
SafeModules = 1 << 0, // SourceFile objects need to be rediscovered, but module resolutions can be reused.
3829-
Completely = 1 << 1, // SourceFile objects and module resolutions can be reused from an old Program.
3827+
Not = 0, // The entire Program must be (re)created.
3828+
SafeProjectReferenceModules = 1 << 0, // SourceFile objects need to be rediscovered, but module resolutions within project reference sources may be reused.
3829+
SafeModules = 1 << 1, // SourceFile objects need to be rediscovered, but module resolutions can be reused.
3830+
Completely = 1 << 2, // SourceFile objects and module resolutions can be reused from an old Program.
38303831
}
38313832

38323833
export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer;

0 commit comments

Comments
 (0)