my fork of the bluesky client
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.resolveRequest = (context, moduleName, platform) => {
18 // HACK: manually resolve a few packages that use `exports` in `package.json`.
19 // A proper solution is to enable `unstable_enablePackageExports` but this needs careful testing.
20 if (moduleName.startsWith('multiformats/hashes/hasher')) {
21 return context.resolveRequest(
22 context,
23 'multiformats/dist/src/hashes/hasher',
24 platform,
25 )
26 }
27 if (moduleName.startsWith('multiformats/cid')) {
28 return context.resolveRequest(
29 context,
30 'multiformats/dist/src/cid',
31 platform,
32 )
33 }
34 if (moduleName === '@ipld/dag-cbor') {
35 return context.resolveRequest(context, '@ipld/dag-cbor/src', platform)
36 }
37 if (process.env.BSKY_PROFILE) {
38 if (moduleName.endsWith('ReactNativeRenderer-prod')) {
39 return context.resolveRequest(
40 context,
41 moduleName.replace('-prod', '-profiling'),
42 platform,
43 )
44 }
45 }
46 return context.resolveRequest(context, moduleName, platform)
47}
48
49cfg.transformer.getTransformOptions = async () => ({
50 transform: {
51 experimentalImportSupport: true,
52 inlineRequires: true,
53 nonInlinedRequires: [
54 // We can remove this option and rely on the default after
55 // https://github.com/facebook/metro/pull/1390 is released.
56 'React',
57 'react',
58 'react-compiler-runtime',
59 'react/jsx-dev-runtime',
60 'react/jsx-runtime',
61 'react-native',
62 ],
63 },
64})
65
66module.exports = cfg