@@ -169,7 +169,6 @@ export interface ResolutionWithFailedLookupLocations {
169
169
failedLookupLocations ?: string [ ] ;
170
170
affectingLocations ?: string [ ] ;
171
171
isInvalidated ?: boolean ;
172
- refCount ?: number ;
173
172
// Files that have this resolution using
174
173
files ?: Set < Path > ;
175
174
alternateResult ?: string ;
@@ -1095,28 +1094,21 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1095
1094
getResolutionWithResolvedFileName : GetResolutionWithResolvedFileName < T , R > ,
1096
1095
deferWatchingNonRelativeResolution : boolean ,
1097
1096
) {
1098
- if ( resolution . refCount ) {
1099
- resolution . refCount ++ ;
1100
- Debug . assertIsDefined ( resolution . files ) ;
1097
+ ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1098
+ if ( resolution . files . size !== 1 ) return ;
1099
+ if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1100
+ watchFailedLookupLocationOfResolution ( resolution ) ;
1101
1101
}
1102
1102
else {
1103
- resolution . refCount = 1 ;
1104
- Debug . assert ( ! resolution . files ?. size ) ; // This resolution shouldnt be referenced by any file yet
1105
- if ( ! deferWatchingNonRelativeResolution || isExternalModuleNameRelative ( name ) ) {
1106
- watchFailedLookupLocationOfResolution ( resolution ) ;
1107
- }
1108
- else {
1109
- nonRelativeExternalModuleResolutions . add ( name , resolution ) ;
1110
- }
1111
- const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1112
- if ( resolved && resolved . resolvedFileName ) {
1113
- const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1114
- let resolutions = resolvedFileToResolution . get ( key ) ;
1115
- if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1116
- resolutions . add ( resolution ) ;
1117
- }
1103
+ nonRelativeExternalModuleResolutions . add ( name , resolution ) ;
1104
+ }
1105
+ const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1106
+ if ( resolved && resolved . resolvedFileName ) {
1107
+ const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
1108
+ let resolutions = resolvedFileToResolution . get ( key ) ;
1109
+ if ( ! resolutions ) resolvedFileToResolution . set ( key , resolutions = new Set ( ) ) ;
1110
+ resolutions . add ( resolution ) ;
1118
1111
}
1119
- ( resolution . files ??= new Set ( ) ) . add ( filePath ) ;
1120
1112
}
1121
1113
1122
1114
function watchFailedLookupLocation ( failedLookupLocation : string , setAtRoot : boolean ) {
@@ -1144,7 +1136,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1144
1136
}
1145
1137
1146
1138
function watchFailedLookupLocationOfResolution ( resolution : ResolutionWithFailedLookupLocations ) {
1147
- Debug . assert ( ! ! resolution . refCount ) ;
1139
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1148
1140
1149
1141
const { failedLookupLocations, affectingLocations, alternateResult } = resolution ;
1150
1142
if ( ! failedLookupLocations ?. length && ! affectingLocations ?. length && ! alternateResult ) return ;
@@ -1165,7 +1157,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1165
1157
}
1166
1158
1167
1159
function watchAffectingLocationsOfResolution ( resolution : ResolutionWithFailedLookupLocations , addToResolutionsWithOnlyAffectingLocations : boolean ) {
1168
- Debug . assert ( ! ! resolution . refCount ) ;
1160
+ Debug . assert ( ! ! resolution . files ?. size ) ;
1169
1161
const { affectingLocations } = resolution ;
1170
1162
if ( ! affectingLocations ?. length ) return ;
1171
1163
if ( addToResolutionsWithOnlyAffectingLocations ) resolutionsWithOnlyAffectingLocations . add ( resolution ) ;
@@ -1381,10 +1373,8 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
1381
1373
syncDirWatcherRemove ?: boolean ,
1382
1374
) {
1383
1375
Debug . checkDefined ( resolution . files ) . delete ( filePath ) ;
1384
- resolution . refCount ! -- ;
1385
- if ( resolution . refCount ) {
1386
- return ;
1387
- }
1376
+ if ( resolution . files ! . size ) return ;
1377
+ resolution . files = undefined ;
1388
1378
const resolved = getResolutionWithResolvedFileName ( resolution ) ;
1389
1379
if ( resolved && resolved . resolvedFileName ) {
1390
1380
const key = resolutionHost . toPath ( resolved . resolvedFileName ) ;
0 commit comments