Repository navigation
Closed
Description
Which project does this relate to?
Router
Describe the bug
If you add the cloudflare vite plugin, the vite dev server will fail to start with an error. (Without this plugin, I have the dev server working.)
import { cloudflare } from "@cloudflare/vite-plugin";
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
cloudflare(),
tanstackStart({
tsr: {
target: 'react',
autoCodeSplitting: true,
verboseFileRoutes: false,
virtualRouteConfig: './routes.ts',
},
target: "cloudflare_module",
}),
],
});Your Example Website or App
Steps to Reproduce the Bug or Issue
git clone https://github.com/jasongitmail/tanstack-vite-cloudflare-repro.git
git checkout 2d0009a # in case I've moved it forward
bun install
bun run build
Expected behavior
Vite dev server should start without error.
Screenshots or Videos
$ vite --port 3000
WARNING: your worker config (at `wrangler.jsonc`) contains the following configuration options which are ignored since they are not applicable when using Vite:
- `build` which is not relevant in the context of a Vite project
error when starting dev server:
Error: The following environment configurations are incompatible with the Cloudflare Vite plugin:
- "tanstack_vite_cloudflare_repro" environment: `resolve.external`: ["undici"]
To resolve this issue, avoid setting `optimizeDeps.exclude` and `resolve.external` in your Cloudflare Worker environments.
at validateWorkerEnvironmentsResolvedConfigs (file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/@cloudflare/vite-plugin/dist/index.js:14267:11)
at configResolved (file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/@cloudflare/vite-plugin/dist/index.js:14363:11)
at file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:49086:67
at Array.map (<anonymous>)
at resolveConfig (file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:49086:53)
at async _createServer (file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:38329:18)
at async CAC.<anonymous> (file:///Users/me/tanstack-vite-cloudflare-repro/node_modules/vite/dist/node/cli.js:753:20)
error: script "dev" exited with code 1Platform
- OS: macOS
- Browser: n/a
- Version:
"@tailwindcss/vite": "^4.1.6",
"@tanstack/react-router": "^1.120.4-alpha.12",
"@tanstack/react-router-devtools": "^1.120.4-alpha.1",
"@tanstack/react-start": "^1.120.4-alpha.12",
"@tanstack/virtual-file-routes": "^1.120.4-alpha.1",
"@cloudflare/vite-plugin": "^1.1.1",
"vite": "^6.1.0",
"wrangler": "^4.14.4"
Additional context
- ordering the cloudflare plugin before or after tanstack plugin makes no difference. both result in this same error.
- Looks like undici is a dependency of
@tanstack/start-server-core, it may be there.
Reacted by Andrei Liviu Georgescu
Metadata
Metadata
Assignees
Labels
No labels
Activity
jasongitmail commentedon May 14, 2025
@schiller-manuel fixed this in a newer alpha release.
As a side note: we also discovered that this plugin doesn't do anything useful right now, since
getPlatformProxy()from wrangler is needed to get the env currently. But Manuel said first class support for Tanstack by@cloudflare/vite-pluginwill be coming.Closing b/c this issue related to a specific error that is now resolved.
andreilgeorgescu commentedon May 21, 2025
So what is currently the recommended way to work with Cloudflare in Tanstack Start/Router?
I followed Cloudflare's Tanstack guide but from what I can tell it requires me to
pnpm run buildprior tonpx wrangler devwhich takes a long time. I'm assuming we have to just wait until the Vite plugin supports Tanstack?HoaX7 commentedon Oct 2, 2025
any update on this?