Skip to content

Commit

Permalink
fix(cjs): isolate implicit resolver enhancement (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Jun 30, 2024
1 parent 6ef949c commit 143a5bd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/cjs/api/module-resolve-filename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ export const createResolveFilename = (
return nextResolve(request, parent, isMain, options);
}

const resolve: SimpleResolve = request_ => nextResolve(
request_,
parent,
isMain,
options,
);

request = interopCjsExports(request);

if (parent?.filename) {
Expand All @@ -198,9 +191,10 @@ export const createResolveFilename = (

// If request namespace doesnt match the namespace, ignore
if ((searchParams.get('namespace') ?? undefined) !== namespace) {
return resolve(request);
return nextResolve(request, parent, isMain, options);
}

let _nextResolve = nextResolve;
if (namespace) {
/**
* When namespaced, the loaders are registered to the extensions in a hidden way
Expand All @@ -209,9 +203,16 @@ export const createResolveFilename = (
* To support implicit extensions, we need to enhance the resolver with our own
* re-implementation of the implicit extension resolution
*/
nextResolve = createImplicitResolver(nextResolve);
_nextResolve = createImplicitResolver(_nextResolve);
}

const resolve: SimpleResolve = request_ => _nextResolve(
request_,
parent,
isMain,
options,
);

let resolved = resolveRequest(requestAndQuery[0], parent, resolve);

// Only add query back if it's a file path (not a core Node module)
Expand Down

0 comments on commit 143a5bd

Please sign in to comment.