Skip to content

Commit 7892cfc

Browse files
committed
refactor(example): switch to default Metro config monorepo setup
1 parent 1377f97 commit 7892cfc

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

apps/example/metro.config.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,25 @@ const { getDefaultConfig } = require('expo/metro-config');
33
const { FileStore } = require('metro-cache');
44
const path = require('path');
55

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);
810

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+
// ];
1921

2022
// Use turborepo to restore the cache when possible
2123
config.cacheStores = [
22-
new FileStore({ root: path.join(projectRoot, 'node_modules', '.cache', 'metro') }),
24+
new FileStore({ root: path.join(__dirname, 'node_modules', '.cache', 'metro') }),
2325
];
2426

2527
module.exports = config;

0 commit comments

Comments
 (0)