react / react/metro

`react-dom/server` cannot be resolved with `unstable_enablePackageExports` and condition `browser`

Open
#1,135 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.6k
Forks
696
Avg merge
8m
Merged PRs (30d)
7

Description

(As reported by @EvanBacon)

Metro cannot resolve react-dom/server with unable_enablePackageExports (and condition browser?), reporting:

warning: Attempted to import the module "/Users/evanbacon/Documents/GitHub/expo/node_modules/react-dom/server.browser.js" which is not listed in the "exports" of "/Users/evanbacon/Documents/GitHub/expo/node_modules/react-dom". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.

Conditions

  unstable_conditionNames: [ 'node', 'require' ],
  unstable_conditionsByPlatform: { web: [ 'browser' ] },

package.json

  "exports": {
    ".": "./index.js",
    "./client": "./client.js",
    "./server": {
      "deno": "./server.browser.js",
      "worker": "./server.browser.js",
      "browser": "./server.browser.js",
      "default": "./server.node.js"
    },
    "./server.browser": "./server.browser.js",
    "./server.node": "./server.node.js",
    "./profiling": "./profiling.js",
    "./test-utils": "./test-utils.js",
    "./package.json": "./package.json"
  },
  "browser": {
    "./server.js": "./server.browser.js"
  },

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the react-dom/server resolution with unstable_enablePackageExports and the shown browser condition. Inspect the package.json exports and browser mappings, including server.browser.js; done when Metro resolves the import without the fallback warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.