Skip to content

Commit 845b18e

Browse files
yamanokuclaude
andcommitted
fix: resolve @vuerend/core in Cloudflare Worker environment
vuerend's resolveId hook redirects @vuerend/core to virtual:vuerend/client-runtime for any environment not named 'server'. The Cloudflare Worker environment is named 'vuefes_japan_speakers', so it incorrectly received the client runtime which lacks defineApp and defineRoute, causing the build to fail with MISSING_EXPORT errors. Add a pre-plugin that intercepts @vuerend/core for non-server/non-client environments and resolves it to the runtime-only entry directly, bypassing vuerend's virtual module. Also remove the wrangler.jsonc `alias` field which is ignored when using the Cloudflare Vite plugin (replaced by Vite's resolve.alias). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 86e0513 commit 845b18e

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

vite.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ const fmt = {
9696

9797
export { fmt, lint };
9898

99+
function cloudflareVuerendRuntime(): Plugin {
100+
return {
101+
name: "vfjs:cloudflare-vuerend-runtime",
102+
enforce: "pre",
103+
resolveId(id) {
104+
if (id !== "@vuerend/core") return;
105+
// Cloudflare Worker environments are not named 'server' or 'client'.
106+
// vuerend's resolve hook redirects @vuerend/core to virtual:vuerend/client-runtime
107+
// for non-server environments, which lacks defineApp/defineRoute.
108+
// Bypass vuerend's virtual module for Worker environments and use the runtime directly.
109+
const { name } = this.environment;
110+
if (name !== "server" && name !== "client") {
111+
return fileURLToPath(
112+
new URL("./node_modules/@vuerend/core/dist/runtime.mjs", import.meta.url),
113+
);
114+
}
115+
},
116+
};
117+
}
118+
99119
function staticHtmlPreview(): Plugin {
100120
return {
101121
name: "vfjs:static-html-preview",
@@ -203,6 +223,7 @@ function cloudflarePages404(): Plugin {
203223

204224
const config: UserConfig = {
205225
plugins: [
226+
cloudflareVuerendRuntime(),
206227
tailwindcss(),
207228
vuerend({
208229
app: "./app/app.ts",

wrangler.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"main": "./dist/server/index.js",
77
"assets": {
88
"directory": "./dist/client",
9-
"binding": "ASSETS"
9+
"binding": "ASSETS",
1010
},
1111
"observability": {
12-
"enabled": true
12+
"enabled": true,
1313
},
1414
}

0 commit comments

Comments
 (0)