Skip to content

Commit

Permalink
Restore base config merge in metro-config (#38092)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38092

Reverts #36777.

This is motivated by reducing user friction when the widespread assumption is for `react-native/metro-config` to export a complete Metro config, as with Expo/rnx-kit, and like previously understood uses of `metro-config`. See facebook/metro#1010 (comment) for further notes.

Fixes:
- facebook/metro#1010
- #38069
- kristerkari/react-native-svg-transformer#276

Note that we do not intend for `react-native/metro-config` to directly export `assetExts` etc — these can be accessed on the `resolver` property from the full config object.

Changelog: [General][Changed] `react-native/metro-config` now includes all base config values from `metro-config`

Reviewed By: robhogan

Differential Revision: D47055973

fbshipit-source-id: 5ad23cc9700397110de5c0e81c7d76299761ef0a
  • Loading branch information
huntie authored and facebook-github-bot committed Jun 28, 2023
1 parent a9618b3 commit bbcedd3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/metro-config/index.js
Expand Up @@ -8,9 +8,9 @@
* @noformat
*/

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

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

const INTERNAL_CALLSITES_REGEX = new RegExp(
[
Expand All @@ -37,8 +37,8 @@ const INTERNAL_CALLSITES_REGEX = new RegExp(
*/
function getDefaultConfig(
projectRoot /*: string */
) /*: MetroConfig */ {
return {
) /*: ConfigT */ {
const config = {
resolver: {
resolverMainFields: ['react-native', 'browser', 'main'],
platforms: ['android', 'ios'],
Expand Down Expand Up @@ -76,6 +76,11 @@ function getDefaultConfig(
},
watchFolders: [],
};

return mergeConfig(
getBaseConfig.getDefaultValues(projectRoot),
config,
);
}

module.exports = {getDefaultConfig, mergeConfig};

0 comments on commit bbcedd3

Please sign in to comment.