Skip to content

Commit cb75678

Browse files
committed
breaking: Remove fallback flow for Metro config defaults (0.73)
Reverts #1896
1 parent 3569633 commit cb75678

File tree

2 files changed

+18
-107
lines changed

2 files changed

+18
-107
lines changed

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

Lines changed: 0 additions & 87 deletions
This file was deleted.

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'fs';
21
import path from 'path';
32
import {
43
ConfigT,
@@ -10,7 +9,6 @@ import {
109
} from 'metro-config';
1110
import {CLIError, logger} from '@react-native-community/cli-tools';
1211
import type {Config} from '@react-native-community/cli-types';
13-
import getDefaultMetroConfig from './getDefaultMetroConfig';
1412
import {reactNativePlatformResolver} from './metroPlatformResolver';
1513

1614
export type {Config};
@@ -20,6 +18,10 @@ export type ConfigLoadingContext = Pick<
2018
'root' | 'reactNativePath' | 'platforms'
2119
>;
2220

21+
declare global {
22+
var __REACT_NATIVE_METRO_CONFIG_LOADED: boolean;
23+
}
24+
2325
/**
2426
* Get the config options to override based on RN CLI inputs.
2527
*/
@@ -97,26 +99,22 @@ export default async function loadMetroConfig(
9799

98100
logger.debug(`Reading Metro config from ${projectConfig.filepath}`);
99101

100-
if (
101-
!/['"']@react-native\/metro-config['"']/.test(
102-
fs.readFileSync(projectConfig.filepath, 'utf8'),
103-
)
104-
) {
105-
logger.warn(
106-
'From React Native 0.72, your metro.config.js file should extend' +
107-
"'@react-native/metro-config'. Please see the React Native 0.72 " +
108-
'changelog, or copy the template at:\n' +
109-
'https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js',
110-
);
111-
logger.warn('Falling back to internal defaults.');
102+
if (!global.__REACT_NATIVE_METRO_CONFIG_LOADED) {
103+
const warning = `
104+
=================================================================================================
112105
113-
const loadedConfig = await loadConfig(
114-
{cwd: ctx.root, ...options},
115-
// Provide React Native defaults on top of Metro defaults
116-
getDefaultMetroConfig(ctx),
117-
);
106+
From React Native 0.73, your project's Metro config should extend '@react-native/metro-config'
107+
or it will fail to build. Please copy the template at:
108+
https://github.com/facebook/react-native/blob/main/packages/react-native/template/metro.config.js
109+
110+
This warning will be removed in future (https://github.com/facebook/metro/issues/1018).
111+
112+
=================================================================================================
113+
`;
118114

119-
return mergeConfig(loadedConfig, overrideConfig);
115+
for (const line of warning.trim().split('\n')) {
116+
logger.warn(line);
117+
}
120118
}
121119

122120
return mergeConfig(

0 commit comments

Comments
 (0)