Skip to content

Docs: Fix stale unstable_conditionNames defaults - #1893

Closed
robhogan wants to merge 1 commit into
mainfrom
pr1893
Closed

Docs: Fix stale unstable_conditionNames defaults#1893
robhogan wants to merge 1 commit into
mainfrom
pr1893

Conversation

@robhogan

@robhogan robhogan commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

unstable_conditionNames is currently documented with stale defaults. We haven't included 'require' (or 'import') since #1447 made Metro assert import/require mutually exclusively per call site, released in Metro 0.82.0. default plus one of import/require is always in the condition set:

https://github.com/react/metro/blob/v0.87.0/packages/metro-resolver/src/utils/matchSubpathFromExportsLike.js#L37-L44

and the configured default is empty:

https://github.com/react/metro/blob/v0.87.0/packages/metro-config/src/defaults/index.js#L50

@react-native/metro-config dropped its static assertion in react/react-native#49780, shipped in RN 0.79.0, and now sets only ['react-native']:

https://github.com/react/react-native/blob/v0.87.1/packages/metro-config/src/index.flow.js#L59

This being wrong might've led people to assume 'import' should be added alongside, which asserts the ESM branch of every package's exports regardless of the call site, and leads to issues such as #1150.

Also updates the worked example under unstable_conditionsByPlatform, and fixes its anchor link (#unstable-conditionnames -> #unstable_conditionnames-experimental).

Changelog: [Internal]

Test plan

Docs-only. (See static docs preview after import)

## Summary

`unstable_conditionNames` hasn't defaulted to `['require']` since #1447 made Metro assert `import`/`require` per call site, released in Metro 0.82.0. `default` plus one of `import`/`require` is always in the condition set:

https://github.com/react/metro/blob/v0.87.0/packages/metro-resolver/src/utils/matchSubpathFromExportsLike.js#L37-L44

and the configured default is empty:

https://github.com/react/metro/blob/v0.87.0/packages/metro-config/src/defaults/index.js#L50

`@react-native/metro-config` dropped its static assertion in react/react-native#49780, shipped in React Native 0.79.0, and now sets `['react-native']`:

https://github.com/react/react-native/blob/v0.87.1/packages/metro-config/src/index.flow.js#L59

This being wrong might've led people to assume `'import'` should be added alongside, which asserts the ESM branch of every package's `exports` regardless of the call site, and leads to issues such as #1150.

Also updates the worked example under `unstable_conditionsByPlatform`, and fixes its anchor link (`#unstable-conditionnames` -> `#unstable_conditionnames-experimental`).

Changelog: [Internal]

## Test plan

Docs-only. Values checked against source (above).
@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 Sep 1, 2026
@robhogan
robhogan marked this pull request as ready for review September 1, 2026 06:51
@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 Sep 1, 2026
@meta-codesync

meta-codesync Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@vzaidman has imported this pull request. If you are a Meta employee, you can view this in D118261403.

@meta-codesync meta-codesync Bot closed this in 7caa324 Sep 2, 2026
@meta-codesync meta-codesync Bot added the Merged label Sep 2, 2026
@meta-codesync

meta-codesync Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@vzaidman merged this pull request in 7caa324.

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. Merged 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