Skip to content

Commit ffb2e9c

Browse files
Use package import instead of relative path, add to performance app
1 parent b026982 commit ffb2e9c

File tree

13 files changed

+20
-43
lines changed

13 files changed

+20
-43
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"packages/core",
4646
"dev-packages/e2e-tests",
4747
"dev-packages/type-check",
48+
"dev-packages/utils",
4849
"samples/react-native",
4950
"samples/react-native-macos",
5051
"samples/expo",
5152
"performance-tests/TestAppPlain",
52-
"performance-tests/TestAppSentry",
53-
"samples/utils"
53+
"performance-tests/TestAppSentry"
5454
],
5555
"//": [
5656
"Appium has a dependency on @xmldom/xmldom@^0.x, which causes chromedrive build to fail yarn install",
Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
const path = require('path');
2-
const exclusionList = require('metro-config/src/defaults/exclusionList');
3-
4-
const projectRoot = __dirname;
5-
const monorepoRoot = path.resolve(projectRoot, '../..');
6-
7-
// Only list the packages within your monorepo that your app uses. No need to add anything else.
8-
// If your monorepo tooling can give you the list of monorepo workspaces linked
9-
// in your app workspace, you can automate this list instead of hardcoding them.
10-
const monorepoPackages = {
11-
'@sentry/react-native': path.resolve(monorepoRoot, 'packages/core'),
12-
};
1+
const { withMonorepo } = require('sentry-react-native-samples-utils/metro');
132

143
/**
154
* Metro configuration for React Native
165
* https://github.com/facebook/react-native
176
*
187
* @format
198
*/
20-
module.exports = {
9+
module.exports = withMonorepo({
2110
transformer: {
2211
getTransformOptions: async () => ({
2312
transform: {
@@ -27,24 +16,4 @@ module.exports = {
2716
}),
2817
},
2918
projectRoot: __dirname,
30-
// 1. Watch the local app directory, and only the shared packages (limiting the scope and speeding it up)
31-
// Note how we change this from `monorepoRoot` to `projectRoot`. This is part of the optimization!
32-
watchFolders: [projectRoot, ...Object.values(monorepoPackages)],
33-
resolver: {
34-
blockList: exclusionList([
35-
...Object.values(monorepoPackages).map(p => new RegExp(`${p}/node_modules/react-native/.*`)),
36-
]),
37-
// Add the monorepo workspaces as `extraNodeModules` to Metro.
38-
// If your monorepo tooling creates workspace symlinks in the `node_modules` directory,
39-
// you can either add symlink support to Metro or set the `extraNodeModules` to avoid the symlinks.
40-
// See: https://metrobundler.dev/docs/configuration/#extranodemodules
41-
extraNodeModules: {
42-
...monorepoPackages,
43-
'react-native': path.resolve(projectRoot, 'node_modules/react-native'),
44-
},
45-
nodeModulesPaths: [
46-
path.resolve(projectRoot, 'node_modules'),
47-
...Object.values(monorepoPackages).map(p => path.resolve(p, 'node_modules')),
48-
],
49-
},
50-
};
19+
});

performance-tests/TestAppSentry/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"devDependencies": {
1616
"@babel/core": "^7.12.9",
1717
"@babel/runtime": "^7.12.5",
18-
"metro-react-native-babel-preset": "^0.72.3"
18+
"metro-react-native-babel-preset": "^0.72.3",
19+
"sentry-react-native-samples-utils": "workspace:^"
1920
},
2021
"jest": {
2122
"preset": "react-native"

samples/expo/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const { getDefaultConfig } = require('@expo/metro-config');
33
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
44

5-
const { withMonorepo } = require('../utils/metro');
5+
const { withMonorepo } = require('sentry-react-native-samples-utils/metro');
66

77
/** @type {import('expo/metro-config').MetroConfig} */
88
const config = getSentryExpoConfig(__dirname, {

samples/expo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"@babel/core": "^7.26.0",
3838
"@babel/preset-env": "^7.26.0",
3939
"@sentry/babel-plugin-component-annotate": "^2.18.0",
40-
"@types/node": "20.10.4"
40+
"@types/node": "20.10.4",
41+
"sentry-react-native-samples-utils": "workspace:^"
4142
},
4243
"overrides": {
4344
"react-refresh": "~0.14.0"

samples/react-native-macos/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { withSentryConfig } = require('@sentry/react-native/metro');
22
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
33

4-
const { withMonorepo } = require('../utils/metro');
4+
const { withMonorepo } = require('sentry-react-native-samples-utils/metro');
55

66
/**
77
* Metro configuration

samples/react-native-macos/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"eslint": "^8.19.0",
5050
"jest": "^29.6.3",
5151
"prettier": "2.8.8",
52+
"sentry-react-native-samples-utils": "workspace:^",
5253
"typescript": "5.0.4"
5354
},
5455
"engines": {

samples/react-native/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { withSentryConfig } = require('@sentry/react-native/metro');
22
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
33

4-
const { withMonorepo } = require('../utils/metro');
4+
const { withMonorepo } = require('sentry-react-native-samples-utils/metro');
55

66
/**
77
* Metro configuration

samples/react-native/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"patch-package": "^8.0.0",
6464
"prettier": "2.8.8",
6565
"react-test-renderer": "18.3.1",
66+
"sentry-react-native-samples-utils": "workspace:^",
6667
"typescript": "5.0.4"
6768
},
6869
"engines": {

yarn.lock

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9484,6 +9484,7 @@ __metadata:
94849484
metro-react-native-babel-preset: ^0.72.3
94859485
react: 18.1.0
94869486
react-native: 0.70.15
9487+
sentry-react-native-samples-utils: "workspace:^"
94879488
languageName: unknown
94889489
linkType: soft
94899490

@@ -24200,6 +24201,7 @@ __metadata:
2420024201
react-native-safe-area-context: 4.12.0
2420124202
react-native-screens: ~4.0.0
2420224203
react-native-web: ~0.19.13
24204+
sentry-react-native-samples-utils: "workspace:^"
2420324205
typescript: ^5.3.2
2420424206
languageName: unknown
2420524207
linkType: soft
@@ -24242,6 +24244,7 @@ __metadata:
2424224244
react-native-vector-icons: ^10.0.3
2424324245
react-redux: ^8.1.3
2424424246
redux: ^4.2.1
24247+
sentry-react-native-samples-utils: "workspace:^"
2424524248
typescript: 5.0.4
2424624249
languageName: unknown
2424724250
linkType: soft
@@ -24290,13 +24293,14 @@ __metadata:
2429024293
react-redux: ^8.1.3
2429124294
react-test-renderer: 18.3.1
2429224295
redux: ^4.2.1
24296+
sentry-react-native-samples-utils: "workspace:^"
2429324297
typescript: 5.0.4
2429424298
languageName: unknown
2429524299
linkType: soft
2429624300

24297-
"sentry-react-native-samples-utils@workspace:samples/utils":
24301+
"sentry-react-native-samples-utils@workspace:^, sentry-react-native-samples-utils@workspace:dev-packages/utils":
2429824302
version: 0.0.0-use.local
24299-
resolution: "sentry-react-native-samples-utils@workspace:samples/utils"
24303+
resolution: "sentry-react-native-samples-utils@workspace:dev-packages/utils"
2430024304
dependencies:
2430124305
metro-config: ^0.81.0
2430224306
languageName: unknown

0 commit comments

Comments
 (0)