mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1// Learn more https://docs.expo.io/guides/customizing-metro
2const {getDefaultConfig} = require('expo/metro-config')
3const cfg = getDefaultConfig(__dirname)
4
5cfg.resolver.sourceExts = process.env.RN_SRC_EXT
6 ? process.env.RN_SRC_EXT.split(',').concat(cfg.resolver.sourceExts)
7 : cfg.resolver.sourceExts
8
9if (cfg.resolver.resolveRequest) {
10 throw Error('Update this override because it is conflicting now.')
11}
12
13if (process.env.BSKY_PROFILE) {
14 cfg.cacheVersion += ':PROFILE'
15}
16
17cfg.resolver.assetExts = [...cfg.resolver.assetExts, 'woff2']
18
19cfg.resolver.resolveRequest = (context, moduleName, platform) => {
20 // HACK: manually resolve a few packages that use `exports` in `package.json`.
21 // A proper solution is to enable `unstable_enablePackageExports` but this needs careful testing.
22 if (moduleName.startsWith('multiformats/hashes/hasher')) {
23 return context.resolveRequest(
24 context,
25 'multiformats/dist/src/hashes/hasher',
26 platform,
27 )
28 }
29 if (moduleName.startsWith('multiformats/cid')) {
30 return context.resolveRequest(
31 context,
32 'multiformats/dist/src/cid',
33 platform,
34 )
35 }
36 if (moduleName === '@ipld/dag-cbor') {
37 return context.resolveRequest(context, '@ipld/dag-cbor/src', platform)
38 }
39 if (process.env.BSKY_PROFILE) {
40 if (moduleName.endsWith('ReactNativeRenderer-prod')) {
41 return context.resolveRequest(
42 context,
43 moduleName.replace('-prod', '-profiling'),
44 platform,
45 )
46 }
47 }
48 return context.resolveRequest(context, moduleName, platform)
49}
50
51cfg.transformer.getTransformOptions = async () => ({
52 transform: {
53 experimentalImportSupport: true,
54 inlineRequires: true,
55 nonInlinedRequires: [
56 // We can remove this option and rely on the default after
57 // https://github.com/facebook/metro/pull/1390 is released.
58 'React',
59 'react',
60 'react-compiler-runtime',
61 'react/jsx-dev-runtime',
62 'react/jsx-runtime',
63 'react-native',
64 ],
65 },
66})
67
68module.exports = cfg