Skip to content

Resolve setup-env from the Metro project root - #58258

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/resolve-setup-env-from-project-root
Open

Resolve setup-env from the Metro project root#58258
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/resolve-setup-env-from-project-root

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

@react-native/metro-config currently resolves react-native/setup-env relative to its own package location. In strict or multi-version installs, that can select a different React Native copy—or fail—even though the configured projectRoot contains the correct export.

Resolve the bootstrap module with require.resolve(..., {paths: [projectRoot]}), matching community-cli-plugin's existing project-scoped behavior. This does not change normal single-version layouts; it makes the existing projectRoot contract deterministic across package-manager layouts.

Changelog:

[GENERAL] [FIXED] - Resolve the React Native setup module from the configured Metro project root.

Test Plan:

  • Built metro-config and verified the generated configuration resolves the same react-native/setup-env as require.resolve(..., {paths: [projectRoot]}) for a separate React Native project.
  • A synthetic strict project fixture reproduced the baseline selecting the repository React Native; the patch selected <projectRoot>/node_modules/react-native/setup-env.js.
  • yarn build metro-config
  • fresh full Flow check: 0 errors
  • targeted ESLint and Prettier checks
  • git diff --check

metro-config currently has no Jest tests. Its source wrapper loads index.flow.js, which the root Jest Node transform leaves as ESM, so a direct package test fails before execution; this change therefore uses built-output resolution verification rather than adding a bespoke compile/eval-only harness for the one-line fix.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant