Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Metro's default resolver processes each of these fields according to the [`brows

:::note

When Metro is started via the React Native CLI, `resolverMainFields` defaults to `['react-native', 'browser', 'main']`.
When using React Native, `resolverMainFields` defaults to `['react-native', 'browser', 'main']`.

:::

Expand Down Expand Up @@ -340,11 +340,11 @@ The set of [condition names](https://nodejs.org/docs/latest-v18.x/api/packages.h

Conditions may be any string value and are resolved in the order specified by each package. Node.js documents a number of [community conditions](https://nodejs.org/docs/latest-v18.x/api/packages.html#community-conditions-definitions) which are commonly used by package authors. The `default` condition is always matched.

Defaults to `['import', 'require']`.
Defaults to `['require']`.

:::note

When Metro is started via React Native CLI, `conditionNames` defaults to `['import', 'require', 'react-native']`.
When using React Native, `unstable_conditionNames` defaults to `['require', 'react-native']`.

:::

Expand All @@ -360,7 +360,7 @@ This setting will take effect when [`unstable_enablePackageExports`](#unstable_e

The set of additional [condition names](https://nodejs.org/docs/latest-v18.x/api/packages.html#conditional-exports) to dynamically assert by platform (see [`platforms`](#platforms)) when interpreting the [`"exports"` field](https://nodejs.org/docs/latest-v18.x/api/packages.html#exports) in package.json.

Matched conditions are merged with [`unstable_conditionNames`](#unstable-conditionnames) before resolution. With the defaults for both options, the conditions `new Set(['import', 'require', 'browser'])` will be asserted when requesting a `web` bundle, and `new Set(['import', 'require'])` otherwise. Again, these are resolved in the order specified by each package.
Matched conditions are merged with [`unstable_conditionNames`](#unstable-conditionnames) before resolution. With the defaults for both options, the conditions `new Set(['require', 'browser'])` will be asserted when requesting a `web` bundle, and `new Set(['require'])` otherwise. Again, these are resolved in the order specified by each package.

Defaults to `‌{ web: ['browser'] }`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Object {
"tsx",
],
"unstable_conditionNames": Array [
"import",
"require",
],
"unstable_conditionsByPlatform": Object {
Expand Down Expand Up @@ -251,7 +250,6 @@ Object {
"tsx",
],
"unstable_conditionNames": Array [
"import",
"require",
],
"unstable_conditionsByPlatform": Object {
Expand Down Expand Up @@ -428,7 +426,6 @@ Object {
"tsx",
],
"unstable_conditionNames": Array [
"import",
"require",
],
"unstable_conditionsByPlatform": Object {
Expand Down Expand Up @@ -605,7 +602,6 @@ Object {
"tsx",
],
"unstable_conditionNames": Array [
"import",
"require",
],
"unstable_conditionsByPlatform": Object {
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-config/src/defaults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const getDefaultValues = (projectRoot: ?string): ConfigT => ({
nodeModulesPaths: [],
resolveRequest: null,
resolverMainFields: ['browser', 'main'],
unstable_conditionNames: ['import', 'require'],
unstable_conditionNames: ['require'],
unstable_conditionsByPlatform: {
web: ['browser'],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-resolver/src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function createResolutionContext(
resolveHasteModule: (name: string) => null,
resolveHastePackage: (name: string) => null,
sourceExts: ['js', 'jsx', 'json', 'ts', 'tsx'],
unstable_conditionNames: ['import', 'require'],
unstable_conditionNames: ['require'],
unstable_conditionsByPlatform: {
web: ['browser'],
},
Expand Down