@vitejs/plugin-rsc vendors react-server-dom-webpack as raw CJS into dist/vendor/react-server-dom/. These files use require() and module.exports.
On pure ESM runtimes (Cloudflare Workers, Deno Deploy), production builds can fail with "require is not defined" or "exports is not defined" when the CJS vendor code leaks into ESM chunks.
Reproduction: https://github.com/remorses/vite-rsc-cloudflare-cjs-repro
pnpm install
pnpm reproduce
The repro is based on the official examples/starter-extra Cloudflare setup and locks @vitejs/plugin-rsc to 0.5.21. pnpm reproduce builds with the Cloudflare Vite plugin and fails because the RSC output still contains the CJS react-server-dom-webpack-server.edge.production.js bundle.
Fix in #1203.
@vitejs/plugin-rscvendorsreact-server-dom-webpackas raw CJS intodist/vendor/react-server-dom/. These files userequire()andmodule.exports.On pure ESM runtimes (Cloudflare Workers, Deno Deploy), production builds can fail with
"require is not defined"or"exports is not defined"when the CJS vendor code leaks into ESM chunks.Reproduction: https://github.com/remorses/vite-rsc-cloudflare-cjs-repro
The repro is based on the official
examples/starter-extraCloudflare setup and locks@vitejs/plugin-rscto0.5.21.pnpm reproducebuilds with the Cloudflare Vite plugin and fails because the RSC output still contains the CJSreact-server-dom-webpack-server.edge.production.jsbundle.Fix in #1203.