Skip to content

Commit b205164

Browse files
fix(web): Fix web build error with React 19
This commit introduces two changes to fix the web build for Expo 53 and React 19. First, it creates a separate entry point for the web build (`index.web.js`) that uses the `createRoot` API from `react-dom/client`. This is necessary for React 19. Second, it adds a `metro.config.js` file to fix a module resolution issue with `react-native`. The configuration forces Metro to resolve `react-native` from the project's `node_modules`, which prevents the `Unable to resolve "../Utilities/Platform"` error.
1 parent 4f24794 commit b205164

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

frontend/metro.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { getDefaultConfig } = require('expo/metro-config');
2+
const path = require('path');
3+
4+
const projectRoot = __dirname;
5+
const workspaceRoot = path.resolve(projectRoot, '../..');
6+
7+
const config = getDefaultConfig(projectRoot);
8+
9+
// 1. Watch all files in the monorepo
10+
config.watchFolders = [workspaceRoot];
11+
// 2. Let Metro know where to resolve packages and in what order
12+
config.resolver.nodeModulesPaths = [
13+
path.resolve(projectRoot, 'node_modules'),
14+
path.resolve(workspaceRoot, 'node_modules'),
15+
];
16+
// 3. Force Metro to resolve certain dependencies from the project root
17+
config.resolver.extraNodeModules = {
18+
'react-native': path.resolve(projectRoot, 'node_modules/react-native'),
19+
};
20+
21+
module.exports = config;

0 commit comments

Comments
 (0)