Open
Description
React version: 19.10.0
Steps To Reproduce
- Run under Bun and Node and see the export differense without a reason
import { createServer } from "node:http";
import { renderToPipeableStream } from "react-dom/server"; // in bun it uses server.bun and in node server.node
function App() {
return <div>Hello World</div>;
}
function handleRequest(res) {
// ... in your server handler ...
const stream = renderToPipeableStream(<App />, {
onShellReady() {
res.statusCode = 200;
res.setHeader("Content-type", "text/html");
stream.pipe(res);
},
// ...
});
}
const http = createServer((req, res) => handleRequest(res));
http.listen(3000, () => {
console.log("Server is running on port 3000");
});
> bun .\a.tsx
1 | (function (entry, fetcher)
^
SyntaxError: Export named 'renderToPipeableStream' not found in module '...\node_modules\react-dom\server.bun.js'.
at loadAndEvaluateModule (1:11)
Bun v1.2.17-canary.50+41d10ed01 (Windows x64)
> bunx tsx .\a.tsx
Server is running on port 3000
as we can see it really missing here: https://github.com/facebook/react/blob/main/packages/react-dom/src/server/ReactDOMFizzServerBun.js
It works fine if you force .node export:
import { createServer } from "node:http";
import { renderToPipeableStream } from "react-dom/server.node";
function App() {
return <div>Hello World</div>;
}
function handleRequest(res) {
// ... in your server handler ...
const stream = renderToPipeableStream(<App />, {
onShellReady() {
res.statusCode = 200;
res.setHeader("Content-type", "text/html");
stream.pipe(res);
},
// ...
});
}
const http = createServer((req, res) => handleRequest(res));
http.listen(3000, () => {
console.log("Server is running on port 3000");
});
The current behavior
Export named 'renderToPipeableStream' not found in module '...\node_modules\react-dom\server.bun.js'.
It brokes react-router usage on Bun
The expected behavior
It should works as in node export