Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
drop getApproximateSpecifier function
Browse files Browse the repository at this point in the history
drop the `getApproximateSpecifier` function which I am not completely
sure why/if it's actually needed
  • Loading branch information
dario-piotrowicz committed Sep 23, 2024
1 parent 8daf491 commit 4ee6525
Showing 1 changed file with 0 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,8 @@ export function getModuleFallbackCallback(resolveId: ResolveIdFunction) {
const { resolveMethod, referrer, specifier, rawSpecifier } =
extractModuleFallbackValues(request);

const referrerDir = dirname(referrer);

let fixedSpecifier = specifier;

if (!/node_modules/.test(referrerDir)) {
// for app source code strip prefix and prepend /
fixedSpecifier = '/' + getApproximateSpecifier(specifier, referrerDir);
} else if (!specifier.endsWith('.js')) {
// for package imports from other packages strip prefix
fixedSpecifier = getApproximateSpecifier(specifier, referrerDir);
}

fixedSpecifier = rawSpecifier;

let resolvedId = await resolveId(
Expand Down Expand Up @@ -146,13 +136,6 @@ function extractModuleFallbackValues(request: Request): {
};
}

function getApproximateSpecifier(target: string, referrerDir: string): string {
let result = '';
if (/^(node|cloudflare|workerd):/.test(target)) result = target;
result = relative(referrerDir, target);
return result;
}

/**
* In the module fallback service we can easily end up with referrers without a javascript (any) file extension.
*
Expand Down

0 comments on commit 4ee6525

Please sign in to comment.