-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetro.config.js
More file actions
58 lines (51 loc) · 1.57 KB
/
Copy pathmetro.config.js
File metadata and controls
58 lines (51 loc) · 1.57 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
55
56
57
58
const path = require('path');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const root = path.resolve(__dirname, '..');
const libraryPath = path.resolve(root, 'src');
// Packages that should be resolved from example's node_modules
// to avoid duplicate React instances
const packagesToResolve = [
'react',
'react-native',
'react-native-reanimated',
'react-native-nitro-modules',
'react-native-gesture-handler',
'react-native-safe-area-context',
'react-native-screens',
'react-native-worklets',
];
/**
* Metro configuration for the example app
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
watchFolders: [root, libraryPath],
resolver: {
// Ensure these packages resolve to example's node_modules
// This prevents duplicate React instances in monorepo
extraNodeModules: new Proxy(
{
// Library source
'react-native-shared-transition': libraryPath,
},
{
get: (target, name) => {
if (target.hasOwnProperty(name)) {
return target[name];
}
// Resolve from example's node_modules first
return path.resolve(__dirname, 'node_modules', name);
},
}
),
nodeModulesPaths: [
path.resolve(__dirname, 'node_modules'),
path.resolve(root, 'node_modules'),
],
// Disable hierarchical lookup to prevent finding packages in parent node_modules
disableHierarchicalLookup: true,
},
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config);