@@ -3,23 +3,25 @@ const { getDefaultConfig } = require('expo/metro-config');
3
3
const { FileStore } = require ( 'metro-cache' ) ;
4
4
const path = require ( 'path' ) ;
5
5
6
- const projectRoot = __dirname ;
7
- const workspaceRoot = path . resolve ( projectRoot , '../..' ) ;
6
+ // Create the default Expo config for Metro
7
+ // This includes the automatic monorepo configuration
8
+ // See: https://docs.expo.dev/guides/monorepos/#automatic-configuration
9
+ const config = getDefaultConfig ( __dirname ) ;
8
10
9
- const config = getDefaultConfig ( projectRoot ) ;
10
-
11
- // Since we are using pnpm, we have to setup the monorepo manually for Metro
12
- // #1 - Watch all files in the monorepo
13
- config . watchFolders = [ workspaceRoot ] ;
14
- // #2 - Try resolving with project modules first, then workspace modules
15
- config . resolver . nodeModulesPaths = [
16
- path . resolve ( projectRoot , 'node_modules' ) ,
17
- path . resolve ( workspaceRoot , 'node_modules' ) ,
18
- ] ;
11
+ // You can configure it manually as well, the most important parts are:
12
+ // const projectRoot = __dirname;
13
+ // const workspaceRoot = path.join(__dirname, '..', '..');
14
+ // #1 - Watch all files within the monorepo
15
+ // config.watchFolders = [workspaceRoot];
16
+ // #2 - Try resolving with project modules first, then hoisted workspace modules
17
+ // config.resolver.nodeModulesPaths = [
18
+ // path.resolve(projectRoot, 'node_modules'),
19
+ // path.resolve(workspaceRoot, 'node_modules'),
20
+ // ];
19
21
20
22
// Use turborepo to restore the cache when possible
21
23
config . cacheStores = [
22
- new FileStore ( { root : path . join ( projectRoot , 'node_modules' , '.cache' , 'metro' ) } ) ,
24
+ new FileStore ( { root : path . join ( __dirname , 'node_modules' , '.cache' , 'metro' ) } ) ,
23
25
] ;
24
26
25
27
module . exports = config ;
0 commit comments