Skip to content
This repository was archived by the owner on May 17, 2025. It is now read-only.

Commit 24ce3e0

Browse files
committed
fix: CJS resolve case
1 parent 14e1f10 commit 24ce3e0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/trace/resolver.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,29 +378,30 @@ export class Resolver {
378378
// subfolder checks before file checks because of fetch
379379
if (await this.exists(url + "/package.json")) {
380380
const pcfg = (await this.getPackageConfig(url)) || {};
381+
const urlUrl = new URL(url + '/');
381382
if (this.env.includes("browser") && typeof pcfg.browser === "string")
382383
return this.finalizeResolve(
383-
await legacyMainResolve.call(this, pcfg.browser, new URL(url)),
384+
await legacyMainResolve.call(this, pcfg.browser, urlUrl),
384385
parentIsCjs,
385386
exportsResolution,
386387
pkgUrl
387388
);
388389
if (this.env.includes("module") && typeof pcfg.module === "string")
389390
return this.finalizeResolve(
390-
await legacyMainResolve.call(this, pcfg.module, new URL(url)),
391+
await legacyMainResolve.call(this, pcfg.module, urlUrl),
391392
parentIsCjs,
392393
exportsResolution,
393394
pkgUrl
394395
);
395396
if (typeof pcfg.main === "string")
396397
return this.finalizeResolve(
397-
await legacyMainResolve.call(this, pcfg.main, new URL(url)),
398+
await legacyMainResolve.call(this, pcfg.main, urlUrl),
398399
parentIsCjs,
399400
exportsResolution,
400401
pkgUrl
401402
);
402403
return this.finalizeResolve(
403-
await legacyMainResolve.call(this, null, new URL(url)),
404+
await legacyMainResolve.call(this, null, urlUrl),
404405
parentIsCjs,
405406
exportsResolution,
406407
pkgUrl

0 commit comments

Comments
 (0)