-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmetro.config.js
More file actions
54 lines (48 loc) Β· 2.54 KB
/
metro.config.js
File metadata and controls
54 lines (48 loc) Β· 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { withNativeWind } = require('nativewind/metro');
const path = require('path');
const {
getSentryExpoConfig
} = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Web-only module resolution hacks
// These overrides only apply when platform === 'web' and fix
// issues that arise from bundling React Native code for the browser.
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
config.resolver.resolveRequest = (context, moduleName, platform) => {
if (platform === 'web') {
// ββ 1. tslib ESM/CJS interop ββββββββββββββββββββββββββββββ
// framer-motion (pulled in via moti) imports tslib's ESM entry
// which Metro can't resolve correctly. Force the CJS build.
if (moduleName === 'tslib') {
return {
filePath: path.resolve(__dirname, 'node_modules/tslib/tslib.js'),
type: 'sourceFile',
};
}
// ββ 2. zustand ESM import.meta.env issue ββββββββββββββββββ
// zustand's ESM build uses import.meta.env which Metro doesn't
// support. Force the CJS build for zustand and its sub-paths.
if (moduleName === 'zustand' || moduleName.startsWith('zustand/')) {
const subpath = moduleName === 'zustand' ? 'index.js' : moduleName.replace('zustand/', '') + '.js';
const filePath = path.resolve(__dirname, 'node_modules/zustand', subpath);
return {
filePath,
type: 'sourceFile',
};
}
// ββ 3. @gorhom/bottom-sheet web shim ββββββββββββββββββββββ
// BottomSheetTextInput and other internals crash on web.
// Redirect to our lightweight shim that re-exports only the
// components we actually use. Skip if the import originates
// from the shim itself to avoid circular resolution.
if (moduleName === '@gorhom/bottom-sheet' && !context.originModulePath?.includes('shims/')) {
return {
filePath: path.resolve(__dirname, 'shims/gorhom-bottom-sheet.web.ts'),
type: 'sourceFile',
};
}
}
return context.resolveRequest(context, moduleName, platform);
};
module.exports = withNativeWind(config, { input: './global.css' });