@@ -235,15 +235,31 @@ export class ModuleGraph {
235
235
rawUrl : string ,
236
236
ssr ?: boolean ,
237
237
setIsSelfAccepting = true ,
238
+ ) : Promise < ModuleNode > {
239
+ return this . _ensureEntryFromUrl ( rawUrl , ssr , setIsSelfAccepting )
240
+ }
241
+
242
+ /**
243
+ * @internal
244
+ */
245
+ async _ensureEntryFromUrl (
246
+ rawUrl : string ,
247
+ ssr ?: boolean ,
248
+ setIsSelfAccepting = true ,
249
+ // Optimization, avoid resolving the same url twice if the caller already did it
250
+ resolved ?: PartialResolvedId ,
238
251
) : Promise < ModuleNode > {
239
252
// Quick path, if we already have a module for this rawUrl (even without extension)
240
253
rawUrl = removeImportQuery ( removeTimestampQuery ( rawUrl ) )
241
254
let mod = this . _getUnresolvedUrlToModule ( rawUrl , ssr )
242
255
if ( mod ) {
243
256
return mod
244
257
}
245
-
246
- const [ url , resolvedId , meta ] = await this . _resolveUrl ( rawUrl , ssr )
258
+ const [ url , resolvedId , meta ] = await this . _resolveUrl (
259
+ rawUrl ,
260
+ ssr ,
261
+ resolved ,
262
+ )
247
263
mod = this . idToModuleMap . get ( resolvedId )
248
264
if ( ! mod ) {
249
265
mod = new ModuleNode ( url , setIsSelfAccepting )
@@ -334,8 +350,12 @@ export class ModuleGraph {
334
350
/**
335
351
* @internal
336
352
*/
337
- async _resolveUrl ( url : string , ssr ?: boolean ) : Promise < ResolvedUrl > {
338
- const resolved = await this . resolveId ( url , ! ! ssr )
353
+ async _resolveUrl (
354
+ url : string ,
355
+ ssr ?: boolean ,
356
+ alreadyResolved ?: PartialResolvedId ,
357
+ ) : Promise < ResolvedUrl > {
358
+ const resolved = alreadyResolved ?? ( await this . resolveId ( url , ! ! ssr ) )
339
359
const resolvedId = resolved ?. id || url
340
360
if (
341
361
url !== resolvedId &&
0 commit comments