File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1221,6 +1221,9 @@ namespace ts {
1221
1221
function doesStructuralPermitResolutionsReuse ( ) : boolean {
1222
1222
switch ( structuralIsReused ) {
1223
1223
case StructureIsReused . Not : return false ;
1224
+ case StructureIsReused . SafeProjectReferenceModules :
1225
+ return file . resolvedModules !== undefined &&
1226
+ isSourceOfProjectReferenceRedirect ( file . originalFileName ) ;
1224
1227
case StructureIsReused . SafeModules : return true ;
1225
1228
case StructureIsReused . Completely : return true ;
1226
1229
@@ -1293,7 +1296,10 @@ namespace ts {
1293
1296
1294
1297
function tryReuseStructureFromOldProgram ( ) : StructureIsReused {
1295
1298
if ( ! oldProgram ) {
1296
- return StructureIsReused . Not ;
1299
+ // During initial program creation, root files may import files from project
1300
+ // references that were previously loaded. Those resolutions are safe to reuse
1301
+ // since another program instance kept them up to date.
1302
+ return StructureIsReused . SafeProjectReferenceModules ;
1297
1303
}
1298
1304
1299
1305
// check properties that can affect structure of the program or module resolution strategy
Original file line number Diff line number Diff line change @@ -3824,9 +3824,10 @@ namespace ts {
3824
3824
/* @internal */
3825
3825
/** "Structure" refers to the SourceFile graph of a Program linked by module resolutions. */
3826
3826
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.
3830
3831
}
3831
3832
3832
3833
export type CustomTransformerFactory = ( context : TransformationContext ) => CustomTransformer ;
You can’t perform that action at this time.
0 commit comments