mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Restore base config merge in metro-config (#38092)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38092 Reverts https://github.com/facebook/react-native/pull/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 https://github.com/facebook/metro/issues/1010#issuecomment-1609215165 for further notes. Fixes: - https://github.com/facebook/metro/issues/1010 - https://github.com/facebook/react-native/issues/38069 - https://github.com/kristerkari/react-native-svg-transformer/issues/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a9618b33be
commit
bbcedd385b
@@ -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(
|
||||
[
|
||||
@@ -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'],
|
||||
@@ -76,6 +76,11 @@ function getDefaultConfig(
|
||||
},
|
||||
watchFolders: [],
|
||||
};
|
||||
|
||||
return mergeConfig(
|
||||
getBaseConfig.getDefaultValues(projectRoot),
|
||||
config,
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {getDefaultConfig, mergeConfig};
|
||||
|
||||
Reference in New Issue
Block a user