You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rsc): convert vendored react-server-dom-webpack to ESM
The vendor-react-server-dom build plugin copies react-server-dom-webpack
into dist/vendor/ as raw CJS files. These files use require() and
module.exports which break on pure ESM runtimes (Cloudflare Workers,
Deno Deploy) where require() does not exist.
When a framework builds for Cloudflare Workers with resolve.noExternal
set to true, the CJS vendor files end up in the production bundle
verbatim, causing "require is not defined" and "exports is not defined"
at deploy time. This is hard to debug because it only affects ESM-only
runtimes in production builds; Node.js and dev mode work fine.
The fix adds an esbuild conversion step after the fs.cpSync in the
tsdown build config. For each CJS entry file (server.edge.js,
client.edge.js, client.browser.js, etc.), it:
1. Bundles with esbuild (format: esm, bundle: true) to inline the
./cjs/*.production.js require chain
2. Replaces __require("react") with top-level ESM imports (esbuild
can not lift requires from __commonJS wrappers to import statements)
3. Removes the __require shim that references the require global
4. Extracts named exports from CJS exports.xxx patterns and generates
proper ESM export var { ... } = default
5. Removes the now-unused cjs/ subdirectory
Session: ses_22b5a7d8affeczTeFI1DGoYPd5
0 commit comments