Skip to content

Commit

Permalink
squash! code to test cloudflare/workerd#2131
Browse files Browse the repository at this point in the history
more clean up and splitting up the namespace into _vite_bare_ and _vite_externals_
  • Loading branch information
IgorMinar committed May 20, 2024
1 parent 1be5528 commit 8e1f76e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const modules = {
export const foo = " foo" + bar`,
},
"/_bare_/bar": {
redirect: "/_bare_/bar/index.js",
"/_vite_bare_/bar": {
redirect: "/_vite_externals_/Users/Dario/project/my-project/node_modules/bar/index.js",
},
"/_bare_/bar/index.js": {
"/_vite_externals_/Users/Dario/project/my-project/node_modules/bar/index.js": {
esModule: `
import {baz} from "./baz.js";
export const bar = " bar" + baz`,
},
"/_bare_/bar/baz.js": {
"/_vite_externals_/Users/Dario/project/my-project/node_modules/bar/baz.js": {
esModule: `
export const baz = " baz"`,
},
Expand Down Expand Up @@ -59,19 +59,20 @@ const mf = new Miniflare({
rawSpecifier :

// let's check if this is the original bare import or an internal redirect to satisfy it
specifier === modules[`/_bare_/${rawSpecifier}`].redirect ?
// this is an internal redirect from /_bare_/bar to /_bare_/bar/index.js
specifier === modules[`/_vite_bare_/${rawSpecifier}`].redirect ?
// this is an internal redirect from /_vite_bare_/bar to /_vite_bare_/bar/index.js
specifier :
// this is a package import, resolve it by prefixing the specifier with '/_bare_/`
`/_bare_/${rawSpecifier}`;
// this is a package import, resolve it by prefixing the specifier with '/_vite_bare_/`
`/_vite_bare_/${rawSpecifier}`;

console.log(`--- Fallback service debug info ---
console.log(`\n--- Fallback service debug info ---
resolve method: ${resolveMethod}
url: ${url}
specifier: ${specifier}
raw specifier: ${rawSpecifier}
referrer: ${referrer}
resolved specifier: ${resolvedSpecifier}`
resolved specifier: ${resolvedSpecifier}
`
);

if (specifier !== resolvedSpecifier) {
Expand Down

0 comments on commit 8e1f76e

Please sign in to comment.