Skip to content

Commit

Permalink
feat: Add alternative base config check to loadMetroConfig (11.x) (#1990
Browse files Browse the repository at this point in the history
)
  • Loading branch information
huntie authored Jun 29, 2023
1 parent 00f83bb commit 704b49a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/cli-plugin-metro/src/tools/loadMetroConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export type ConfigLoadingContext = Pick<
'root' | 'reactNativePath' | 'platforms'
>;

declare global {
var __REACT_NATIVE_METRO_CONFIG_LOADED: boolean;
}

/**
* Get the config options to override based on RN CLI inputs.
*/
Expand Down Expand Up @@ -98,6 +102,9 @@ export default async function loadMetroConfig(
logger.debug(`Reading Metro config from ${projectConfig.filepath}`);

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

0 comments on commit 704b49a

Please sign in to comment.