Skip to content

Commit 1fc7eba

Browse files
authored
breaking: Remove fallback flow for Metro config defaults (0.73) (#1972)
Reverts #1896
1 parent aa9efcb commit 1fc7eba

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
*/
@@ -98,26 +100,22 @@ export default async function loadMetroConfig(
98100

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

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

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

123121
return mergeConfig(

0 commit comments

Comments
 (0)