|
1 | 1 | const path = require('path'); |
2 | | -const escape = require('escape-string-regexp'); |
3 | 2 | const { getDefaultConfig } = require('@expo/metro-config'); |
4 | | -const exclusionList = require('metro-config/src/defaults/exclusionList'); |
5 | | -const pak = require('../package.json'); |
| 3 | +const { withMetroConfig } = require('react-native-monorepo-config'); |
6 | 4 |
|
7 | 5 | const root = path.resolve(__dirname, '..'); |
8 | | -const modules = Object.keys({ ...pak.peerDependencies }); |
9 | | - |
10 | | -const defaultConfig = getDefaultConfig(__dirname); |
11 | 6 |
|
12 | 7 | /** |
13 | 8 | * Metro configuration |
14 | 9 | * https://facebook.github.io/metro/docs/configuration |
15 | 10 | * |
16 | 11 | * @type {import('metro-config').MetroConfig} |
17 | 12 | */ |
18 | | -const config = { |
19 | | - ...defaultConfig, |
20 | | - |
21 | | - projectRoot: __dirname, |
22 | | - watchFolders: [root], |
23 | | - |
24 | | - // We need to make sure that only one version is loaded for peerDependencies |
25 | | - // So we block them at the root, and alias them to the versions in example's node_modules |
26 | | - resolver: { |
27 | | - ...defaultConfig.resolver, |
28 | | - |
29 | | - blacklistRE: exclusionList( |
30 | | - modules.map( |
31 | | - (m) => |
32 | | - new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) |
33 | | - ) |
34 | | - ), |
| 13 | +const config = withMetroConfig(getDefaultConfig(__dirname), { |
| 14 | + root, |
| 15 | + dirname: __dirname, |
| 16 | +}); |
35 | 17 |
|
36 | | - extraNodeModules: modules.reduce((acc, name) => { |
37 | | - acc[name] = path.join(__dirname, 'node_modules', name); |
38 | | - return acc; |
39 | | - }, {}), |
40 | | - }, |
41 | | -}; |
| 18 | +config.resolver.unstable_enablePackageExports = true; |
42 | 19 |
|
43 | 20 | module.exports = config; |
0 commit comments