Skip to content

Commit cce2b25

Browse files
authored
[MOB-9131] Symlink the SDK in the sample app (#675)
* Symlink the SDK in the sample app * Fix `test_sample` CI job * Add `@babel/runtime` to Metro's exclusion list * Get Metro excluded packages from `peerDependencies` Instead of hard coding `react` and `react-native` in Metro's exclusion list of modules I added them to `package.json` as `peerDependencies` and then dynamically imported them in `metro.config.js` in order to decouple `metro.config.js` from changes to `package.json`.
1 parent 445aee9 commit cce2b25

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
steps:
4949
- checkout:
5050
path: ~/project
51-
51+
- run: yarn
5252
- run: cd InstabugSample && yarn install
5353

5454
- run:

InstabugSample/metro.config.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
* @format
66
*/
77

8+
const path = require('path');
9+
const escape = require('escape-string-regexp');
10+
const exclusionList = require('metro-config/src/defaults/exclusionList');
11+
const pkg = require('../package.json');
12+
13+
const root = path.resolve(__dirname, '..');
14+
const peerDependencies = Object.keys(pkg.peerDependencies);
15+
const modules = [...peerDependencies, '@babel/runtime'];
16+
817
module.exports = {
18+
watchFolders: [root],
919
transformer: {
1020
getTransformOptions: async () => ({
1121
transform: {
@@ -14,5 +24,13 @@ module.exports = {
1424
},
1525
}),
1626
},
17-
maxWorkers: 2,
27+
resolver: {
28+
blacklistRE: exclusionList(
29+
modules.map(m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)),
30+
),
31+
extraNodeModules: modules.reduce((acc, name) => {
32+
acc[name] = path.join(__dirname, 'node_modules', name);
33+
return acc;
34+
}, {}),
35+
},
1836
};

InstabugSample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@react-navigation/bottom-tabs": "^6.0.9",
1414
"@react-navigation/native": "^6.0.6",
15-
"instabug-reactnative": "../",
15+
"instabug-reactnative": "link:../",
1616
"react": "17.0.2",
1717
"react-native": "0.66.0",
1818
"react-native-safe-area-context": "^3.3.2",

InstabugSample/yarn.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,8 +3557,9 @@ ini@^1.3.4:
35573557
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
35583558
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==
35593559

3560-
instabug-reactnative@../:
3561-
version "10.13.0"
3560+
"instabug-reactnative@link:..":
3561+
version "0.0.0"
3562+
uid ""
35623563

35633564
internal-slot@^1.0.3:
35643565
version "1.0.3"

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"esprima": "^4.0.1",
4545
"typescript": "^4.0.3"
4646
},
47+
"peerDependencies": {
48+
"react": "*",
49+
"react-native": "*"
50+
},
4751
"jest": {
4852
"preset": "react-native",
4953
"modulePathIgnorePatterns": [

0 commit comments

Comments
 (0)