@@ -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 ;
@@ -1072,28 +1071,21 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1072
1071
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1073
1072
deferWatchingNonRelativeResolution : boolean ,
1074
1073
) {
1075
- if ( resolution . refCount ) {
1076
- resolution . refCount ++ ;
1077
- Debug . assertIsDefined ( resolution . files ) ;
1074
+ ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1075
+ if ( resolution . files . size !== 1 ) return ;
1076
+ if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1077
+ watchFailedLookupLocationOfResolution ( resolution ) ;
1078
1078
}
1079
1079
else {
1080
- resolution . refCount = 1 ;
1081
- Debug . assert ( ! resolution . files ?. size ) ; // This resolution shouldnt be referenced by any file yet
1082
- if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1083
- watchFailedLookupLocationOfResolution ( resolution ) ;
1084
- }
1085
- else {
1086
- nonRelativeExternalModuleResolutions . add ( resolution ) ;
1087
- }
1088
- const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1089
- if ( resolved && resolved . resolvedFileName ) {
1090
- const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1091
- let resolutions = resolvedFileToResolution . get ( key ) ;
1092
- if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1093
- resolutions . add ( resolution ) ;
1094
- }
1080
+ nonRelativeExternalModuleResolutions . add ( resolution ) ;
1081
+ }
1082
+ const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1083
+ if ( resolved && resolved . resolvedFileName ) {
1084
+ const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1085
+ let resolutions = resolvedFileToResolution . get ( key ) ;
1086
+ if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1087
+ resolutions . add ( resolution ) ;
1095
1088
}
1096
- ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1097
1089
}
1098
1090
1099
1091
function watchFailedLookupLocation ( failedLookupLocation : string , setAtRoot : boolean ) {
@@ -1120,7 +1112,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1120
1112
}
1121
1113
1122
1114
function watchFailedLookupLocationOfResolution ( resolution : ResolutionWithFailedLookupLocations ) {
1123
- Debug . assert ( ! ! resolution . refCount ) ;
1115
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1124
1116
1125
1117
const { failedLookupLocations, affectingLocations, node10Result } = resolution ;
1126
1118
if ( ! failedLookupLocations ?. length && ! affectingLocations ?. length && ! node10Result ) return ;
@@ -1141,7 +1133,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1141
1133
}
1142
1134
1143
1135
function watchAffectingLocationsOfResolution ( resolution : ResolutionWithFailedLookupLocations , addToResolutionsWithOnlyAffectingLocations : boolean ) {
1144
- Debug . assert ( ! ! resolution . refCount ) ;
1136
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1145
1137
const { affectingLocations } = resolution ;
1146
1138
if ( ! affectingLocations ?. length ) return ;
1147
1139
if ( addToResolutionsWithOnlyAffectingLocations ) resolutionsWithOnlyAffectingLocations . add ( resolution ) ;
@@ -1261,10 +1253,8 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1261
1253
syncDirWatcherRemove ?: boolean ,
1262
1254
) {
1263
1255
Debug . checkDefined ( resolution . files ) . delete ( filePath ) ;
1264
- resolution . refCount ! -- ;
1265
- if ( resolution . refCount ) {
1266
- return ;
1267
- }
1256
+ if ( resolution . files ! . size ) return ;
1257
+ resolution . files = undefined ;
1268
1258
const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1269
1259
if ( resolved && resolved . resolvedFileName ) {
1270
1260
const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
0 commit comments