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