|
1 |
| -const path = require('path'); |
2 | 1 | const { withSentryConfig } = require('@sentry/react-native/metro');
|
3 | 2 | const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
4 |
| -const exclusionList = require('metro-config/src/defaults/exclusionList'); |
5 | 3 |
|
6 |
| -const projectRoot = __dirname; |
7 |
| -const monorepoRoot = path.resolve(projectRoot, '../..'); |
8 |
| - |
9 |
| -// Only list the packages within your monorepo that your app uses. No need to add anything else. |
10 |
| -// If your monorepo tooling can give you the list of monorepo workspaces linked |
11 |
| -// in your app workspace, you can automate this list instead of hardcoding them. |
12 |
| -const monorepoPackages = { |
13 |
| - '@sentry/react-native': path.resolve(monorepoRoot, 'packages/core'), |
14 |
| -}; |
| 4 | +const { withMonorepo } = require('sentry-react-native-samples-utils/metro'); |
15 | 5 |
|
16 | 6 | /**
|
17 | 7 | * Metro configuration
|
18 | 8 | * https://facebook.github.io/metro/docs/configuration
|
19 | 9 | *
|
20 | 10 | * @type {import('metro-config').MetroConfig}
|
21 | 11 | */
|
22 |
| -const config = { |
23 |
| - projectRoot: __dirname, |
24 |
| - // 1. Watch the local app directory, and only the shared packages (limiting the scope and speeding it up) |
25 |
| - // Note how we change this from `monorepoRoot` to `projectRoot`. This is part of the optimization! |
26 |
| - watchFolders: [projectRoot, ...Object.values(monorepoPackages)], |
27 |
| - resolver: { |
28 |
| - resolverMainFields: ['react-native', 'main'], |
29 |
| - resolveRequest: (context, moduleName, platform) => { |
30 |
| - if (moduleName.includes('promise/')) { |
31 |
| - return context.resolveRequest( |
32 |
| - { |
33 |
| - ...context, |
34 |
| - // Ensures the promise module is resolved from the sample's node_modules. |
35 |
| - allowHaste: false, |
36 |
| - disableHierarchicalLookup: true, |
37 |
| - }, |
38 |
| - moduleName, |
39 |
| - platform, |
40 |
| - ); |
41 |
| - } |
42 |
| - return context.resolveRequest(context, moduleName, platform); |
43 |
| - }, |
44 |
| - blockList: exclusionList([ |
45 |
| - new RegExp('.*\\android\\.*'), // Required for Windows in order to run the Sample. |
46 |
| - ...Object.values(monorepoPackages).map( |
47 |
| - p => new RegExp(`${p}/node_modules/react-native/.*`), |
48 |
| - ), |
49 |
| - ]), |
50 |
| - // Add the monorepo workspaces as `extraNodeModules` to Metro. |
51 |
| - // If your monorepo tooling creates workspace symlinks in the `node_modules` directory, |
52 |
| - // you can either add symlink support to Metro or set the `extraNodeModules` to avoid the symlinks. |
53 |
| - // See: https://metrobundler.dev/docs/configuration/#extranodemodules |
54 |
| - extraNodeModules: { |
55 |
| - ...monorepoPackages, |
56 |
| - 'react-native': path.resolve(projectRoot, 'node_modules/react-native'), |
57 |
| - }, |
58 |
| - nodeModulesPaths: [ |
59 |
| - path.resolve(projectRoot, 'node_modules'), |
60 |
| - ...Object.values(monorepoPackages).map(p => |
61 |
| - path.resolve(p, 'node_modules'), |
62 |
| - ), |
63 |
| - ], |
64 |
| - }, |
65 |
| -}; |
| 12 | +const config = {}; |
| 13 | + |
| 14 | +const mergedConfig = mergeConfig(getDefaultConfig(__dirname), config); |
66 | 15 |
|
67 |
| -const m = mergeConfig(getDefaultConfig(__dirname), config); |
68 |
| -module.exports = withSentryConfig(m, { |
| 16 | +const sentryConfig = withSentryConfig(mergedConfig, { |
69 | 17 | annotateReactComponents: true,
|
70 | 18 | });
|
| 19 | + |
| 20 | +module.exports = withMonorepo(sentryConfig); |
0 commit comments