diff --git a/packages/community-cli-plugin/src/utils/loadMetroConfig.js b/packages/community-cli-plugin/src/utils/loadMetroConfig.js index a41b028fa29..9b6a79ee104 100644 --- a/packages/community-cli-plugin/src/utils/loadMetroConfig.js +++ b/packages/community-cli-plugin/src/utils/loadMetroConfig.js @@ -14,7 +14,6 @@ import type {MetroConfig} from 'metro'; import {CLIError} from './errors'; import {reactNativePlatformResolver} from './metroPlatformResolver'; import {loadConfig, resolveConfig} from 'metro'; -import path from 'path'; const debug = require('debug')('ReactNative:CommunityCliPlugin'); @@ -25,7 +24,6 @@ export type {Config}; export type ConfigLoadingContext = Readonly<{ root: Config['root'], - reactNativePath: Config['reactNativePath'], platforms: Config['platforms'], ... }>; @@ -63,9 +61,7 @@ function getCommunityCliDefaultConfig( // We can include multiple copies of setup-env here because Metro will // only add ones that are already part of the bundle getModulesRunBeforeMainModule: () => [ - // NOTE: ctx.reactNativePath is an absolute path, therefore we need to - // reference setup-env.js here by exact path specifier. - require.resolve(path.join(ctx.reactNativePath, 'src/setup-env.js'), { + require.resolve('react-native/setup-env', { paths: [ctx.root], }), ...outOfTreePlatforms.map(platform => diff --git a/packages/metro-config/src/index.flow.js b/packages/metro-config/src/index.flow.js index dcac214b397..74fc4053c2b 100644 --- a/packages/metro-config/src/index.flow.js +++ b/packages/metro-config/src/index.flow.js @@ -59,7 +59,7 @@ export function getDefaultConfig(projectRoot: string): ConfigT { unstable_conditionNames: ['react-native'], }, serializer: { - // Note: This option is overridden in cli-plugin-metro (getOverrideConfig) + // NOTE: Overridden in community-cli-plugin getModulesRunBeforeMainModule: () => [ require.resolve('react-native/setup-env'), ],