Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add alternative base config check to loadMetroConfig (11.x) #1990

Merged
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
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