|
1 | | -const path = require('path'); |
| 1 | +const path = require('node:path'); |
| 2 | +const fs = require('node:fs'); |
2 | 3 | const { getDefaultConfig } = require('@expo/metro-config'); |
3 | | -const { withMetroConfig } = require('react-native-monorepo-config'); |
| 4 | +const { makeMetroConfig } = require('@rnx-kit/metro-config'); |
4 | 5 |
|
5 | | -const root = path.resolve(__dirname, '..'); |
| 6 | +const exampleWorkspace = path.resolve(__dirname, '.'); |
| 7 | +const nativescriptJsi = path.resolve(__dirname, '..'); |
| 8 | +const monorepoRoot = path.resolve(__dirname, '../../..'); |
| 9 | + |
| 10 | +const allNodeModules = [ |
| 11 | + path.resolve(exampleWorkspace, 'node_modules'), |
| 12 | + path.resolve(nativescriptJsi, 'node_modules'), |
| 13 | + path.resolve(monorepoRoot, 'node_modules'), |
| 14 | +]; |
6 | 15 |
|
7 | 16 | /** |
8 | 17 | * Metro configuration |
9 | 18 | * https://facebook.github.io/metro/docs/configuration |
10 | 19 | * |
11 | 20 | * @type {import('metro-config').MetroConfig} |
12 | 21 | */ |
13 | | -const config = withMetroConfig(getDefaultConfig(__dirname), { |
14 | | - root, |
15 | | - dirname: __dirname, |
16 | | -}); |
| 22 | +const config = makeMetroConfig(getDefaultConfig(__dirname)); |
| 23 | + |
| 24 | +config.resolver.nodeModulesPaths = allNodeModules; |
| 25 | +config.resolver.extraNodeModules = { |
| 26 | + 'nativescript-jsi': nativescriptJsi, |
| 27 | +}; |
| 28 | + |
| 29 | +config.watchFolders = [ |
| 30 | + ...allNodeModules.filter((filePath) => fs.existsSync(filePath)), |
| 31 | + nativescriptJsi, |
| 32 | +]; |
| 33 | +console.log(config.watchFolders); |
17 | 34 |
|
18 | 35 | module.exports = config; |
0 commit comments