const { getDefaultConfig } = require('expo/metro-config'); const path = require('path'); const projectRoot = __dirname; const workspaceRoot = path.resolve(projectRoot, '..'); const config = getDefaultConfig(projectRoot); // 1. Keep the project root to the current folder to ensure assets are found correctly config.projectRoot = projectRoot; // 2. Watch all files within the monorepo for changes config.watchFolders = [workspaceRoot]; // 3. Explicitly tell Metro where to look for modules // We prioritize local node_modules, then workspace node_modules config.resolver.nodeModulesPaths = [ path.resolve(projectRoot, 'node_modules'), path.resolve(workspaceRoot, 'node_modules'), ]; // 4. Force resolution of React and React Native config.resolver.extraNodeModules = { 'react': path.resolve(projectRoot, 'node_modules/react'), 'react-native': path.resolve(projectRoot, 'node_modules/react-native'), '@react-native/assets-registry': path.resolve(projectRoot, 'node_modules/@react-native/assets-registry'), }; module.exports = config;