1- const fs = require ( 'fs' ) ;
2- const path = require ( 'path' ) ;
3- const { getDefaultConfig, mergeConfig} = require ( '@react-native/metro-config' ) ;
4- const exclusionList = require ( 'metro-config/src/defaults/exclusionList' ) ;
5- const escape = require ( 'escape-string-regexp' ) ;
1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+ const { getDefaultConfig, mergeConfig } = require ( '@react-native/metro-config' )
4+ const exclusionList = require ( 'metro-config/src/defaults/exclusionList' )
5+ const escape = require ( 'escape-string-regexp' )
66
7- const root = path . resolve ( __dirname , '..' ) ;
8- const rootNodeModulesPath = path . join ( root , 'node_modules' ) ;
9- const exampleNodeModulesPath = path . join ( __dirname , 'node_modules' ) ;
7+ const root = path . resolve ( __dirname , '..' )
8+ const rootNodeModulesPath = path . join ( root , 'node_modules' )
9+ const exampleNodeModulesPath = path . join ( __dirname , 'node_modules' )
1010
1111function getPackageNames ( nodeModulesPath ) {
1212 if ( ! fs . existsSync ( nodeModulesPath ) ) {
13- return [ ] ;
13+ return [ ]
1414 }
1515
16- const allFiles = fs . readdirSync ( nodeModulesPath ) ;
16+ const allFiles = fs . readdirSync ( nodeModulesPath )
1717
1818 // Filter out only directories (package names)
19- const packageNames = allFiles . filter ( file => {
20- const filePath = path . join ( nodeModulesPath , file ) ;
21- return fs . statSync ( filePath ) . isDirectory ( ) ;
22- } ) ;
19+ const packageNames = allFiles . filter ( ( file ) => {
20+ const filePath = path . join ( nodeModulesPath , file )
21+ return fs . statSync ( filePath ) . isDirectory ( )
22+ } )
2323
2424 // Handle scoped packages (e.g., @scope/package)
2525 const scopedPackages = packageNames
26- . filter ( pkg => pkg . startsWith ( '@' ) )
27- . flatMap ( scope => {
28- const scopePath = path . join ( nodeModulesPath , scope ) ;
29- const scopedFiles = fs . readdirSync ( scopePath ) ;
30- return scopedFiles . map ( scopedFile => `${ scope } /${ scopedFile } ` ) ;
31- } ) ;
26+ . filter ( ( pkg ) => pkg . startsWith ( '@' ) )
27+ . flatMap ( ( scope ) => {
28+ const scopePath = path . join ( nodeModulesPath , scope )
29+ const scopedFiles = fs . readdirSync ( scopePath )
30+ return scopedFiles . map ( ( scopedFile ) => `${ scope } /${ scopedFile } ` )
31+ } )
3232
3333 // Return both regular and scoped package names
3434 return packageNames
35- . filter ( pkg => ! pkg . startsWith ( '@' ) )
36- . concat ( scopedPackages ) ;
35+ . filter ( ( pkg ) => ! pkg . startsWith ( '@' ) )
36+ . concat ( scopedPackages )
3737}
3838
39- const exampleNodeModules = getPackageNames ( exampleNodeModulesPath ) ;
39+ const exampleNodeModules = getPackageNames ( exampleNodeModulesPath )
4040
4141const config = {
4242 projectRoot : __dirname ,
@@ -48,7 +48,8 @@ const config = {
4848 unstable_enableSymlinks : true ,
4949 blockList : exclusionList (
5050 exampleNodeModules . map (
51- m => new RegExp ( `^${ escape ( path . join ( rootNodeModulesPath , m ) ) } \\/.*$` ) ,
51+ ( m ) =>
52+ new RegExp ( `^${ escape ( path . join ( rootNodeModulesPath , m ) ) } \\/.*$` ) ,
5253 ) ,
5354 ) ,
5455
@@ -70,6 +71,6 @@ const config = {
7071 } ,
7172 } ) ,
7273 } ,
73- } ;
74+ }
7475
75- module . exports = mergeConfig ( getDefaultConfig ( __dirname ) , config ) ;
76+ module . exports = mergeConfig ( getDefaultConfig ( __dirname ) , config )
0 commit comments