1+ /**
2+ * Metro configuration for React Native
3+ * https://github.com/facebook/react-native
4+ *
5+ * @format
6+ */
17const path = require ( 'path' ) ;
2- const { getDefaultConfig } = require ( 'metro-config' ) ;
38const exclusionList = require ( 'metro-config/src/defaults/exclusionList' ) ;
9+ const { getDefaultConfig, mergeConfig } = require ( '@react-native/metro-config' ) ;
410const escape = require ( 'escape-string-regexp' ) ;
511const pak = require ( '../package.json' ) ;
6-
712const root = path . resolve ( __dirname , '..' ) ;
813
9- const { resolver : defaultResolver } = getDefaultConfig . getDefaultValues ( ) ;
14+ const defaultConfig = getDefaultConfig ( __dirname ) ;
15+ const {
16+ resolver : { sourceExts, assetExts } ,
17+ } = getDefaultConfig ( __dirname ) ;
1018
1119const modules = Object . keys ( {
1220 ...pak . peerDependencies ,
1321} ) ;
1422
15- module . exports = {
23+ const config = {
1624 projectRoot : __dirname ,
1725 watchFolders : [ root ] ,
18-
1926 // We need to make sure that only one version is loaded for peerDependencies
2027 // So we exclude them at the root, and alias them to the versions in example's node_modules
2128 resolver : {
@@ -25,15 +32,13 @@ module.exports = {
2532 new RegExp ( `^${ escape ( path . join ( root , 'node_modules' , m ) ) } \\/.*$` )
2633 )
2734 ) ,
28-
2935 extraNodeModules : modules . reduce ( ( acc , name ) => {
3036 acc [ name ] = path . join ( __dirname , 'node_modules' , name ) ;
3137 return acc ;
3238 } , { } ) ,
33-
34- sourceExts : [ ...defaultResolver . sourceExts , 'cjs' ] ,
39+ assetExts ,
40+ sourceExts : [ ...sourceExts , 'cjs' ] ,
3541 } ,
36-
3742 transformer : {
3843 getTransformOptions : async ( ) => ( {
3944 transform : {
@@ -43,3 +48,5 @@ module.exports = {
4348 } ) ,
4449 } ,
4550} ;
51+
52+ module . exports = mergeConfig ( defaultConfig , config ) ;
0 commit comments