Skip to content
20 linesCodeBlameRaw
1// Metro in the g1t monorepo. Expo finds the workspace root and
2// @g1t/contracts by itself; what it needs told is that React comes from
3// this app alone. The site pins a newer React at the root, and React
4// Native must run with the exact React it was built for (19.2.3 with
5// Expo SDK 57), so `react` and its subpaths resolve from here wherever
6// they are imported, including from packages hoisted to the root.
7const path = require("node:path");
8const { getDefaultConfig } = require("expo/metro-config");
9
10const config = getDefaultConfig(__dirname);
11const here = path.join(__dirname, "package.json");
12
13const resolveRequest = config.resolver.resolveRequest;
14config.resolver.resolveRequest = (context, moduleName, platform) => {
15 const pinned = moduleName === "react" || moduleName.startsWith("react/");
16 const from = pinned ? { ...context, originModulePath: here } : context;
17 return resolveRequest ? resolveRequest(from, moduleName, platform) : context.resolveRequest(from, moduleName, platform);
18};
19
20module.exports = config;