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

Commit

Permalink
drop getApproximateSpecifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Sep 23, 2024
1 parent 8daf491 commit dbcab86
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/vite-environment-provider-cloudflare/src/moduleFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export function getModuleFallbackCallback(resolveId: ResolveIdFunction) {

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);
}
// 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;

Expand Down Expand Up @@ -146,12 +146,12 @@ 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;
}
// 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 dbcab86

Please sign in to comment.