(type, _hook)
| 262 | }; |
| 263 | compiler.resolverFactory.hooks.resolver.intercept({ |
| 264 | factory(type, _hook) { |
| 265 | /** @typedef {(err?: Error, resolveRequest?: ResolveRequest) => void} ActiveRequest */ |
| 266 | /** @type {Map<string, ActiveRequest[]>} */ |
| 267 | const activeRequests = new Map(); |
| 268 | /** @type {Map<string, [ActiveRequest[], Yield[]]>} */ |
| 269 | const activeRequestsWithYield = new Map(); |
| 270 | const hook = |
| 271 | /** @type {SyncHook<[Resolver, ResolveOptions, ResolveOptionsWithDependencyType]>} */ |
| 272 | (_hook); |
| 273 | hook.tap(PLUGIN_NAME, (resolver, options, userOptions) => { |
| 274 | if ( |
| 275 | /** @type {ResolveOptions & { cache: boolean }} */ |
| 276 | (options).cache !== true |
| 277 | ) { |
| 278 | return; |
| 279 | } |
| 280 | const optionsIdent = objectToString(userOptions, false); |
| 281 | const cacheWithContext = |
| 282 | options.cacheWithContext !== undefined |
| 283 | ? options.cacheWithContext |
| 284 | : false; |
| 285 | resolver.hooks.resolve.tapAsync( |
| 286 | { |
| 287 | name: PLUGIN_NAME, |
| 288 | stage: -100 |
| 289 | }, |
| 290 | (request, resolveContext, callback) => { |
| 291 | if ( |
| 292 | /** @type {ResolveRequestWithCacheMiss} */ |
| 293 | (request)._ResolverCachePluginCacheMiss || |
| 294 | !fileSystemInfo |
| 295 | ) { |
| 296 | return callback(); |
| 297 | } |
| 298 | const withYield = typeof resolveContext.yield === "function"; |
| 299 | const identifier = `${type}${ |
| 300 | withYield ? "|yield" : "|default" |
| 301 | }${optionsIdent}${objectToString(request, !cacheWithContext)}`; |
| 302 | |
| 303 | if (withYield) { |
| 304 | const activeRequest = activeRequestsWithYield.get(identifier); |
| 305 | if (activeRequest) { |
| 306 | activeRequest[0].push(callback); |
| 307 | activeRequest[1].push( |
| 308 | /** @type {Yield} */ |
| 309 | (resolveContext.yield) |
| 310 | ); |
| 311 | return; |
| 312 | } |
| 313 | } else { |
| 314 | const activeRequest = activeRequests.get(identifier); |
| 315 | if (activeRequest) { |
| 316 | activeRequest.push(callback); |
| 317 | return; |
| 318 | } |
| 319 | } |
| 320 | const itemCache = cache.getItemCache(identifier, null); |
| 321 | /** @type {Callback[] | false | undefined} */ |
nothing calls this directly
no test coverage detected