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

feat: Set "react-native" condition when using Package Exports #1862

Merged

Conversation

huntie
Copy link
Collaborator

@huntie huntie commented Mar 7, 2023

Summary:

Provide a default value for the resolver.unstable_conditionNames option when running Metro via React Native CLI (applicable to Metro >0.75.1, merged in #1846), enabling the "react-native" conditional export (see RFC).

Note: This does not set unstable_enablePackageExports by default, as we want this to be an opt-in by the user (which will be documented in an upcoming React Native blog post). However when users have enabled Package Exports, we want the default conditions to be set appropriately.

Screenshot: The intended Metro docs wording for this config merge. This is intentionally equivalent to today's resolverMainFields behaviour.

image

Test Plan:

Manual review

@adamTrz adamTrz merged commit 6a970c6 into react-native-community:main Mar 13, 2023
facebook-github-bot pushed a commit to facebook/metro that referenced this pull request Mar 15, 2023
…et by RN CLI

Summary: See react-native-community/cli#1862.

Reviewed By: jacdebug

Differential Revision: D43876358

fbshipit-source-id: 0b075956ef8e6254beed7c8572b1c99ba9649ffe
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Mar 16, 2023
Summary:
Updates the default set of `"exports"` condition names in our `ReactNativeEnv` for Jest, so that it aligns with the defaults in React Native CLI (react-native-community/cli#1862).

Also includes a subtle update to how this is accomplished. Instead of overriding `exportConditions()`, we assign to the underlying class property — this allows users (once jestjs/jest#13989 is merged) to override `customExportConditions` via [`testEnvironmentOptions`](https://jestjs.io/docs/configuration#testenvironmentoptions-object).

```js
  preset: 'react-native',
  testEnvironmentOptions: {
    customExportConditions: ['test', 'react-native'],
  },
```

Changelog: [Internal]

Reviewed By: jacdebug

Differential Revision: D43879056

fbshipit-source-id: 86fffe2b5fdf9d8492d25b8b12a78be75b5fa3be
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Updates the default set of `"exports"` condition names in our `ReactNativeEnv` for Jest, so that it aligns with the defaults in React Native CLI (react-native-community/cli#1862).

Also includes a subtle update to how this is accomplished. Instead of overriding `exportConditions()`, we assign to the underlying class property — this allows users (once jestjs/jest#13989 is merged) to override `customExportConditions` via [`testEnvironmentOptions`](https://jestjs.io/docs/configuration#testenvironmentoptions-object).

```js
  preset: 'react-native',
  testEnvironmentOptions: {
    customExportConditions: ['test', 'react-native'],
  },
```

Changelog: [Internal]

Reviewed By: jacdebug

Differential Revision: D43879056

fbshipit-source-id: 86fffe2b5fdf9d8492d25b8b12a78be75b5fa3be
@huntie huntie deleted the metro-condition-names-default branch May 25, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants