Skip to content

Bug [React-DOM]: Missing "bun" export field in package.json #28941

@Guibi1

Description

@Guibi1

In the exports field of the react-dom's package.json, there is no "bun" field. Bun defaults to the "default" field for compatibility. However, the ./server.node.js file doesn't export renderToReadableStream(), while Bun supports Web Streams out of the box.

See: The Bun doc on Module resolution
This issue is similar to #26906, but Bun always supported Web Streams so there is no backwards compatibility issues.

React version: 18.3.1

Steps To Reproduce

  1. Install react-dom.
  2. Import renderToReadableStream()
  3. Run the file using Bun
  4. Notice that the error is something like this: SyntaxError: Export named 'renderToReadableStream' not found in module '~/??/node_modules/react-dom/server.node.js'., which clearly shows that Bun uses the default export.

Link to code example:
I am not sure how to use Bun on the browser.

The current behavior

Bun uses the default export. (aka server.node.js)

The expected behavior

Bun uses a custom "bun" export. (aka server.browser.js)

I have tested the following change locally and it completely fixes this issue:

fixed package.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions