reasonml / reason-react

Reason bindings for ReactJS
https://reasonml.github.io/reason-react/
MIT License
3.25k stars 347 forks source link

Bundling errors in ES6 due to `react-dom` having different API in Node and browser #814

Closed jchavarri closed 10 months ago

jchavarri commented 10 months ago

When trying to use the latest reason-react with react 18 using es6 modules in the browser, the bundling step fails with:

WARNING in ../../../_build/default/frontend/all/node_modules/reason-react/ReactDOM.bs.js 59:9-38
export 'renderToPipeableStream' (imported as 'Server') was not found in 'react-dom/server' (possible exports: renderToNodeStream, renderToReadableStream, renderToStaticMarkup, renderToStaticNodeStream, renderToString, version)

I suspect a similar issue happens if one tries to use it from Node, but in that case renderToReadableStream will fail as it's not available in Node.

The reasons are:

A solution could be to move the offending APIs renderToPipeableStream and renderToReadableStream to new libraries react-dom.node-only or react-dom.browser-only.

Ref: https://github.com/facebook/react/issues/24226.