@@ -172,7 +172,6 @@ export interface ResolutionWithFailedLookupLocations {
172
172
failedLookupLocations ?: string [ ] ;
173
173
affectingLocations ?: string [ ] ;
174
174
isInvalidated ?: boolean ;
175
- refCount ?: number ;
176
175
// Files that have this resolution using
177
176
files ?: Set < Path > ;
178
177
node10Result ?: string ;
@@ -1068,28 +1067,21 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1068
1067
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1069
1068
deferWatchingNonRelativeResolution : boolean ,
1070
1069
) {
1071
- if ( resolution . refCount ) {
1072
- resolution . refCount ++ ;
1073
- Debug . assertIsDefined ( resolution . files ) ;
1070
+ ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1071
+ if ( resolution . files . size !== 1 ) return ;
1072
+ if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1073
+ watchFailedLookupLocationOfResolution ( resolution ) ;
1074
1074
}
1075
1075
else {
1076
- resolution . refCount = 1 ;
1077
- Debug . assert ( ! resolution . files ?. size ) ; // This resolution shouldnt be referenced by any file yet
1078
- if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1079
- watchFailedLookupLocationOfResolution ( resolution ) ;
1080
- }
1081
- else {
1082
- nonRelativeExternalModuleResolutions . add ( resolution ) ;
1083
- }
1084
- const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1085
- if ( resolved && resolved . resolvedFileName ) {
1086
- const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1087
- let resolutions = resolvedFileToResolution . get ( key ) ;
1088
- if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1089
- resolutions . add ( resolution ) ;
1090
- }
1076
+ nonRelativeExternalModuleResolutions . add ( resolution ) ;
1077
+ }
1078
+ const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1079
+ if ( resolved && resolved . resolvedFileName ) {
1080
+ const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1081
+ let resolutions = resolvedFileToResolution . get ( key ) ;
1082
+ if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1083
+ resolutions . add ( resolution ) ;
1091
1084
}
1092
- ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1093
1085
}
1094
1086
1095
1087
function watchFailedLookupLocation ( failedLookupLocation : string , setAtRoot : boolean ) {
@@ -1116,7 +1108,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1116
1108
}
1117
1109
1118
1110
function watchFailedLookupLocationOfResolution ( resolution : ResolutionWithFailedLookupLocations ) {
1119
- Debug . assert ( ! ! resolution . refCount ) ;
1111
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1120
1112
1121
1113
const { failedLookupLocations, affectingLocations, node10Result } = resolution ;
1122
1114
if ( ! failedLookupLocations ?. length && ! affectingLocations ?. length && ! node10Result ) return ;
@@ -1137,7 +1129,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1137
1129
}
1138
1130
1139
1131
function watchAffectingLocationsOfResolution ( resolution : ResolutionWithFailedLookupLocations , addToResolutionsWithOnlyAffectingLocations : boolean ) {
1140
- Debug . assert ( ! ! resolution . refCount ) ;
1132
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1141
1133
const { affectingLocations } = resolution ;
1142
1134
if ( ! affectingLocations ?. length ) return ;
1143
1135
if ( addToResolutionsWithOnlyAffectingLocations ) resolutionsWithOnlyAffectingLocations . add ( resolution ) ;
@@ -1256,10 +1248,8 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1256
1248
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1257
1249
) {
1258
1250
Debug . checkDefined ( resolution . files ) . delete ( filePath ) ;
1259
- resolution . refCount ! -- ;
1260
- if ( resolution . refCount ) {
1261
- return ;
1262
- }
1251
+ if ( resolution . files ! . size ) return ;
1252
+ resolution . files = undefined ;
1263
1253
const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1264
1254
if ( resolved && resolved . resolvedFileName ) {
1265
1255
const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
0 commit comments