Occulted Vite errors in dev mode Cloudflare - Error running module "
Reproduction
- Start an RR app using the Cloudflare template:
npx create-react-router@latest --template remix-run/react-router-templates/cloudflare
-
Open /app/routes/home.tsx.
-
Change an import path to an intentionally incorrect one ("../welcome/welcome" → "/blabla").
-
Start the dev server.
npm run dev
System Info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M3
Memory: 261.56 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node
npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm
Browsers:
Chrome: 139.0.7258.68
Safari: 17.5
npmPackages:
@react-router/dev: ^7.7.1 => 7.8.0
react-router: ^7.7.1 => 7.8.0
vite: ^6.3.3 => 6.3.5
Used Package Manager
npm
Expected Behavior
I'm expecting the actual build error to be reported:
Actual Behavior
But I get this instead:
Note: if you launch the dev server before changing the import path, it will surface the right error until you reload the page or get a new HMR update.
Also, I noticed the template is using the unstable_viteEnvironmentApi flag. Might this be the issue?
Shouldn't the default template only rely on stable APIs, given that it's the source of truth and people expect it to work in production?
I have this same error, and it makes development quite hard, as you can have a small typo but you don't know where's the issue.
+1 makes development impossible
Also, I noticed the template is using the
unstable_viteEnvironmentApiflag. Might this be the issue?Shouldn't the default template only rely on stable APIs, given that it's the source of truth and people expect it to work in production?
The Cloudflare Vite plugin relies on Vite env api so RR needs to use it too
Note the Vite api is stable, what's unstable is the support in RR plugin
I got the error a few days ago, but I think the issue is not in RR but in the CF plugin
Same issue. It's making dev extremely difficult as theres no pointers to where the error is 😭
There is an open issue here
I got the error a few days ago, but I think the issue is not in RR but in the CF plugin
Yes it seems like - it’s thrown from the CF plugin code.
As a workaround you can build the app for prod and at least it’ll surface the error
@tavoyne Good trick, thanks.
The update in the Cloudflare Vite plugin should be almost available😄
https://github.com/cloudflare/workers-sdk/pull/10655
Update: fix was released https://github.com/cloudflare/workers-sdk/releases/tag/%40cloudflare/vite-plugin%401.13.2