-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
What versions & operating system are you using?
System:
OS: macOS 15.7.3
CPU: (8) arm64 Apple M1
Memory: 92.11 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 25.2.1 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /Users/andrew/.yarn/bin/yarn
npm: 11.6.2 - /opt/homebrew/bin/npm
bun: 1.3.3 - /Users/andrew/.bun/bin/bun
Deno: 2.5.6 - /opt/homebrew/bin/deno
Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
npmPackages:
@cloudflare/kv-asset-handler: 0.4.2
@cloudflare/unenv-preset: 2.12.0
@cloudflare/vite-plugin: 1.23.1
@cloudflare/workerd-darwin-64: 1.20260205.0
@cloudflare/workerd-darwin-arm64: 1.20260205.0
@cloudflare/workerd-linux-64: 1.20260205.0
@cloudflare/workerd-linux-arm64: 1.20260205.0
@cloudflare/workerd-windows-64: 1.20260205.0
@cloudflare/workers-types: 4.20260207.0
@cloudflare/workers-types: 4.20251118.0
@cloudflare/workers-types: 4.20251118.0
@cloudflare/workers-types: 4.20251118.0
@cloudflare/workers-types: 4.20251118.0
miniflare: 4.20260205.0
wrangler: 4.63.0
Please provide a link to a minimal reproduction
https://github.com/acusti/cloudflare-vite-8-react-router
Describe the Bug
Steps to reproduce with minimal reproduction (based on the official create-cloudflare --framework=react-router scaffold with vite@8.0.0-beta.13 added, no other changes):
- checkout the repo
npm install && npm run build
Production builds (react-router build) fail when @cloudflare/vite-plugin is included in the Vite config with Vite 8. The same project builds successfully with Vite 7 (rollup).
Works: Vite 7.3.1 (Rollup) — produces build/server/wrangler.json with no_bundle: true as expected.
Fails: Vite 8.0.0-beta.13 (Rolldown) — assertion error in output-config plugin.
Note: standalone workers (no framework) build fine on Vite 8. The issue is specific to framework integrations where buildApp orchestrates the SSR environment build.
As far as I can tell (with debugging assistance from Claude Opus 4.6), the underlying problem is that the output-config plugin sets input: { index: VIRTUAL_WORKER_ENTRY } and then asserts that an entry chunk named "index" exists in the bundle output. With Rollup (Vite 7), the entry chunk preserves this name. With Rolldown (Vite 8), it does not, maybe because React Router’s buildApp interacts with the SSR environment’s build configuration differently under Rolldown? I’m speculating. Regardless, standalone workers (no framework buildApp) produce the index chunk correctly on Vite 8, so the issue seems isolated to how framework-driven builds interact with the plugin’s expected output structure.
Without the Cloudflare Vite plugin in production builds, the workaround is to make the plugin dev-only and rely on wrangler deploy (i.e. esbuild) for production bundling, meaning I have a two-stage build where react-router build (Vite) and wrangler deploy (esbuild) each bundle app modules independently, producing duplicate copies of shared modules. This has actually been working fine for me until I tried to migrate to React Router v7’s middleware context API today, which relies on object identity for context keys. The duplicate bundling creates two copies of the context module. set() uses one copy’s key via my main worker.ts file, get() uses the other (from my RR7 routes), and every request fails with No value found for context.
I’m happy to open a companion issue in remix-run/react-router if the fix needs to happen on the React Router side (e.g., ensuring buildApp preserves the environment’s configured rollup input under rolldown). Let me know if that’s the case.
Please provide any relevant error logs
vite v8.0.0-beta.13 building ssr environment for production...
✓ 25 modules transformed.
✗ Build failed in 139ms
Build failed with 1 error:
[plugin vite-plugin-cloudflare:output-config]
AssertionError: Expected entry chunk with name "index"
AssertionError [ERR_ASSERTION]: Expected entry chunk with name "index"
at PluginContextImpl.generateBundle (file:///path/to/cloudflare-vite-8-react-router/node_modules/@cloudflare/vite-plugin/src/plugins/output-config.ts:36:5)
at PluginContextImpl.handler (file:///path/to/cloudflare-vite-8-react-router/node_modules/vite/dist/node/chunks/fetchableEnvironments.js:34371:13)
at plugin (file:///path/to/cloudflare-vite-8-react-router/node_modules/rolldown/dist/shared/bindingify-input-options-CorDub0q.mjs:1396:18)
at plugin.<computed> (file:///path/to/cloudflare-vite-8-react-router/node_modules/rolldown/dist/shared/bindingify-input-options-CorDub0q.mjs:1675:18)
at aggregateBindingErrorsIntoJsError (file:///path/to/cloudflare-vite-8-react-router/node_modules/rolldown/dist/shared/bindingify-input-options-CorDub0q.mjs:628:18)
at unwrapBindingResult (file:///path/to/cloudflare-vite-8-react-router/node_modules/rolldown/dist/shared/bindingify-input-options-CorDub0q.mjs:598:128)
at RolldownBuild.#build (file:///path/to/cloudflare-vite-8-react-router/node_modules/rolldown/dist/shared/rolldown-build-CGNuOAoF.mjs:3345:34)
at buildEnvironment (file:///path/to/cloudflare-vite-8-react-router/node_modules/vite/dist/node/chunks/fetchableEnvironments.js:34111:64)
at build (file:///path/to/cloudflare-vite-8-react-router/node_modules/vite/dist/node/chunks/fetchableEnvironments.js:34533:19)
at async Promise.all (index 0)
at Object.buildApp (/path/to/cloudflare-vite-8-react-router/node_modules/@react-router/dev/dist/vite.js:3329:17)
at Object.buildApp (file:///path/to/cloudflare-vite-8-react-router/node_modules/vite/dist/node/chunks/fetchableEnvironments.js:34525:6)
at viteAppBuild (/path/to/cloudflare-vite-8-react-router/node_modules/@react-router/dev/dist/cli/index.js:1981:3)
at build (/path/to/cloudflare-vite-8-react-router/node_modules/@react-router/dev/dist/cli/index.js:1922:10) {
errors: [Getter/Setter]
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status