Skip to content

Commit 1c4a505

Browse files
huntiefacebook-github-bot
authored andcommitted
Drop internal base config merge in metro-config (#36777)
Summary: Pull Request resolved: #36777 Changelog: [Internal] Remove internal merge of `getDefaultConfig` (Metro base defaults) from `react-native/metro-config`. This is unnecessary given the config loading setup of RN CLI and Expo CLI, which use (or replicate) Metro's [`loadConfig`](https://github.com/facebook/metro/blob/1e47cb5b3cc289530fb18e402891f9d2816611dd/packages/metro-config/src/loadConfig.js#L182-L190) function — which will itself apply defaults appropriately. This relates to a previously-breaking behaviour documented in the test plan of react-native-community/cli#1896 (independently fixed and no longer load-bearing) (**read: no need to cherry pick this change**). https://pxl.cl/2B8NS While this has no effect under the fixed RN CLI setup, this is a worthwhile simplification to this package that better-aligns with current Metro tooling expectations. ## Notes - `getDefaultConfig` no longer returns `ConfigT` (full config), and instead returns `MetroConfig` (partial config). This is non-breaking with the expected API of a given `metro.config.js` file. Reviewed By: cipolleschi Differential Revision: D44630645 fbshipit-source-id: 472c3967449dfb99f845a82d9e9c49efc343021c
1 parent e2116d2 commit 1c4a505

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/metro-config/index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @noformat
99
*/
1010

11-
/*:: import type {ConfigT} from 'metro-config'; */
11+
/*:: import type {MetroConfig} from 'metro-config'; */
1212

13-
const {getDefaultConfig: getBaseConfig, mergeConfig} = require('metro-config');
13+
const {mergeConfig} = require('metro-config');
1414

1515
const INTERNAL_CALLSITES_REGEX = new RegExp(
1616
[
@@ -37,8 +37,8 @@ const INTERNAL_CALLSITES_REGEX = new RegExp(
3737
*/
3838
function getDefaultConfig(
3939
projectRoot /*: string */
40-
) /*: ConfigT */ {
41-
const config = {
40+
) /*: MetroConfig */ {
41+
return {
4242
resolver: {
4343
resolverMainFields: ['react-native', 'browser', 'main'],
4444
platforms: ['android', 'ios'],
@@ -76,11 +76,6 @@ function getDefaultConfig(
7676
},
7777
watchFolders: [],
7878
};
79-
80-
return mergeConfig(
81-
getBaseConfig.getDefaultValues(projectRoot),
82-
config,
83-
);
8479
}
8580

8681
module.exports = {getDefaultConfig, mergeConfig};

0 commit comments

Comments
 (0)