diff --git a/docs/Configuration.md b/docs/Configuration.md index 4af2091e4d..a94d6464ea 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -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']`. ::: @@ -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']`. ::: @@ -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'] }`. diff --git a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap index 1146f694d2..171e8134b5 100644 --- a/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap +++ b/packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap @@ -74,7 +74,6 @@ Object { "tsx", ], "unstable_conditionNames": Array [ - "import", "require", ], "unstable_conditionsByPlatform": Object { @@ -251,7 +250,6 @@ Object { "tsx", ], "unstable_conditionNames": Array [ - "import", "require", ], "unstable_conditionsByPlatform": Object { @@ -428,7 +426,6 @@ Object { "tsx", ], "unstable_conditionNames": Array [ - "import", "require", ], "unstable_conditionsByPlatform": Object { @@ -605,7 +602,6 @@ Object { "tsx", ], "unstable_conditionNames": Array [ - "import", "require", ], "unstable_conditionsByPlatform": Object { diff --git a/packages/metro-config/src/defaults/index.js b/packages/metro-config/src/defaults/index.js index 9c279097f4..e3fee1eb8b 100644 --- a/packages/metro-config/src/defaults/index.js +++ b/packages/metro-config/src/defaults/index.js @@ -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'], }, diff --git a/packages/metro-resolver/src/__tests__/utils.js b/packages/metro-resolver/src/__tests__/utils.js index b98cfaad3c..13ac1ba0bc 100644 --- a/packages/metro-resolver/src/__tests__/utils.js +++ b/packages/metro-resolver/src/__tests__/utils.js @@ -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'], },