Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export named renderToReadableStream not found in module react-dom/server #9949

Closed
gineika opened this issue Apr 4, 2024 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@gineika
Copy link

gineika commented Apr 4, 2024

What version of Bun is running?

1.1.1+ca1dbb4eb

What platform is your computer?

Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

https://bun.sh/guides/ecosystem/ssr-react

What is the expected behavior?

No response

What do you see instead?

SyntaxError: Export named 'renderToReadableStream' not found in module '/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/server.node.js'.

Additional information

Works with v1.0.36

@gineika gineika added the bug Something isn't working label Apr 4, 2024
@yoshikouki
Copy link

yoshikouki commented Apr 8, 2024

I'm same here.

Reproducing script

import reactDomServer from "react-dom/server";
console.log("reactDomServer:", reactDomServer);

Environment

❯ sw_vers
ProductName:            macOS
ProductVersion:         14.4.1
BuildVersion:           23E224

Result by version

In 1.1 series, #renderToPipeableStream exists, so the package for Node.js is imported.

https://react.dev/reference/react-dom/server

❯ bun -v; bun run --bun test.ts
1.0.36
reactDomServer: {
  version: "18.2.0",
  renderToString: [Function: renderToString],
  renderToStaticMarkup: [Function: renderToStaticMarkup],
  renderToNodeStream: [Function: renderToNodeStream],
  renderToStaticNodeStream: [Function: renderToStaticNodeStream],
  renderToReadableStream: [Function: renderToReadableStream],
}
❯ bun -v; bun run --bun test.ts
1.1.0
reactDomServer: {
  version: "18.2.0",
  renderToString: [Function: renderToString],
  renderToStaticMarkup: [Function: renderToStaticMarkup],
  renderToNodeStream: [Function: renderToNodeStream],
  renderToStaticNodeStream: [Function: renderToStaticNodeStream],
  renderToPipeableStream: [Function: renderToPipeableStream],
}
❯ bun -v; bun run --bun test.ts
1.1.3
reactDomServer: {
  version: "18.2.0",
  renderToString: [Function: renderToString],
  renderToStaticMarkup: [Function: renderToStaticMarkup],
  renderToNodeStream: [Function: renderToNodeStream],
  renderToStaticNodeStream: [Function: renderToStaticNodeStream],
  renderToPipeableStream: [Function: renderToPipeableStream],
}

@windwiny
Copy link
Contributor

maybe need use react canary version , then will work..

$ pnpm init
$ pnpm add react@canary react-dom@canary

$ bun -v; bun run --bun test-react.ts
1.1.4
reactDomServer: {
  version: "19.0.0-canary-33a32441e9-20240418",
  renderToReadableStream: [Function: renderToReadableStream],
  renderToString: [Function: renderToString],
  renderToStaticMarkup: [Function: renderToStaticMarkup],
}

@Jarred-Sumner
Copy link
Collaborator

As @windwiny mentioned, please upgrade to react@canary or react@next

bun install react@canary react-dom@canary

Another option you can try is to import from react-dom/server.browser instead:

import {renderToReadableStream} from 'react-dom/server.browser` // <--notice the ".browser" at the end

@iam-medvedev
Copy link

Another option you can try is to import from react-dom/server.browser instead:

Honestly, this is not a solution to the problem. But if you are here too, you need to specify types:

types.d.ts:

declare module 'react-dom/server.browser' {
  export * from 'react-dom/server';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants