Skip to content

Vendored react-server-dom-webpack CJS breaks on ESM-only runtimes (Cloudflare Workers) #1204

@remorses

Description

@remorses

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions