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