38 lines
1.5 KiB
JavaScript
Executable file
38 lines
1.5 KiB
JavaScript
Executable file
// Learn more on how to setup config for the app: https://docs.expo.dev/guides/config-plugins/#metro-config
|
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
const path = require('path');
|
|
|
|
// Find the project root and workspace root
|
|
const projectRoot = __dirname;
|
|
const workspaceRoot = path.resolve(projectRoot, '../..'); // Adjust this path as needed
|
|
|
|
const config = getDefaultConfig(projectRoot);
|
|
|
|
// 1. Watch all files within the monorepo
|
|
config.watchFolders = [workspaceRoot];
|
|
|
|
// 2. Let Metro know where to resolve modules from
|
|
config.resolver.nodeModulesPaths = [
|
|
path.resolve(projectRoot, 'node_modules'),
|
|
path.resolve(workspaceRoot, 'node_modules'),
|
|
];
|
|
|
|
// 3. Force Metro to resolve (sub)dependencies only from the top-level `node_modules`
|
|
config.resolver.disableHierarchicalLookup = true;
|
|
|
|
// 4. Ensure Metro correctly resolves the entry point for expo-router
|
|
// This is crucial for web builds in a monorepo with expo-router
|
|
config.resolver.entryExts = ['js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs'];
|
|
|
|
// 5. Never bundle the Jest test folder (tests/). It lives outside app/, so it
|
|
// is not routed, but blocking it here makes an accidental production import
|
|
// fail loudly instead of silently shipping test code.
|
|
const escapeForRegExp = (value) =>
|
|
value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
|
config.resolver.blockList = [
|
|
...(config.resolver.blockList ? [].concat(config.resolver.blockList) : []),
|
|
new RegExp(`^${escapeForRegExp(path.resolve(projectRoot, 'tests'))}[/\\\\].*$`),
|
|
];
|
|
|
|
module.exports = config;
|