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:
react-dom doesn't have uniform APIs across browser and node implementations.
es6 imports are analyzed statically, so even if the renderToPipeableStream is never called, the resolver tries to solve the import at build time (that's why commonjs works)
A solution could be to move the offending APIs renderToPipeableStream and renderToReadableStream to new libraries react-dom.node-only or react-dom.browser-only.
When trying to use the latest
reason-react
with react 18 using es6 modules in the browser, the bundling step fails with: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:
react-dom
doesn't have uniform APIs across browser and node implementations.renderToPipeableStream
is never called, the resolver tries to solve the import at build time (that's why commonjs works)A solution could be to move the offending APIs
renderToPipeableStream
andrenderToReadableStream
to new librariesreact-dom.node-only
orreact-dom.browser-only
.Ref: https://github.com/facebook/react/issues/24226.