Skip to content

Commit 704b49a

Browse files
authored
feat: Add alternative base config check to loadMetroConfig (11.x) (#1990)
1 parent 00f83bb commit 704b49a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/cli-plugin-metro/src/tools/loadMetroConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export type ConfigLoadingContext = Pick<
2020
'root' | 'reactNativePath' | 'platforms'
2121
>;
2222

23+
declare global {
24+
var __REACT_NATIVE_METRO_CONFIG_LOADED: boolean;
25+
}
26+
2327
/**
2428
* Get the config options to override based on RN CLI inputs.
2529
*/
@@ -98,6 +102,9 @@ export default async function loadMetroConfig(
98102
logger.debug(`Reading Metro config from ${projectConfig.filepath}`);
99103

100104
if (
105+
!global.__REACT_NATIVE_METRO_CONFIG_LOADED &&
106+
// TODO(huntie): Remove this check from 0.73 onwards (all users will be on
107+
// the next major @react-native/metro-config version)
101108
!/['"']@react-native\/metro-config['"']/.test(
102109
fs.readFileSync(projectConfig.filepath, 'utf8'),
103110
)

0 commit comments

Comments
 (0)