Skip to content

Commit adf8381

Browse files
authored
chore: more dev environment fixes (#320)
1 parent be861aa commit adf8381

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.20.0

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git a/index.js b/index.js
2+
index 4dc070a2a6ca0ef3fe4e929509f9d9108debd643..f66a3359800b6720ef848d8b76783ff5d3dfd7e7 100644
3+
--- a/index.js
4+
+++ b/index.js
5+
@@ -133,14 +133,6 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
6+
(m, i, self) => self.lastIndexOf(m) === i // Remove duplicates
7+
);
8+
9+
- // We need to exclude the peerDependencies we've collected in packages' node_modules
10+
- // Otherwise duplicate versions of the same package will be loaded
11+
- const blockList = Object.values(packages).flatMap((dir) =>
12+
- peers.map(
13+
- (m) => new RegExp(`^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`)
14+
- )
15+
- );
16+
-
17+
// When we import a package from the monorepo, metro may not be able to find the deps in blockList
18+
// We need to specify them in `extraNodeModules` to tell metro where to find them
19+
const extraNodeModules = peers.reduce((acc, name) => {
20+
@@ -153,6 +145,20 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
21+
return acc;
22+
}, {});
23+
24+
+ // We need to exclude the peerDependencies we've collected in packages' node_modules
25+
+ // Otherwise duplicate versions of the same package will be loaded
26+
+ const blockList = Object.values(packages).flatMap((dir) =>
27+
+ peers.map((m) => {
28+
+ // Skip blocking items that we've specified in extraNodeModules
29+
+ const peerPath = path.join(dir, 'node_modules', m)
30+
+ if(extraNodeModules[m] === peerPath) {
31+
+ return null;
32+
+ }
33+
+ return new RegExp(`^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`)
34+
+ }
35+
+ )
36+
+ ).filter((value) => value != null);
37+
+
38+
// If monorepo root is a package, add it to extraNodeModules so metro can find it
39+
// Normally monorepo packages are symlinked to node_modules, but the root is not
40+
// So we need to add it manually

example/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,8 @@
199199
}
200200
]
201201
]
202+
},
203+
"resolutions": {
204+
"react-native-monorepo-config@^0.3.1": "patch:react-native-monorepo-config@npm%3A0.3.1#./.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch"
202205
}
203206
}

yarn.lock

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11952,7 +11952,7 @@ __metadata:
1195211952
languageName: node
1195311953
linkType: hard
1195411954

11955-
"react-native-monorepo-config@npm:^0.3.1":
11955+
"react-native-monorepo-config@npm:0.3.1":
1195611956
version: 0.3.1
1195711957
resolution: "react-native-monorepo-config@npm:0.3.1"
1195811958
dependencies:
@@ -11962,6 +11962,16 @@ __metadata:
1196211962
languageName: node
1196311963
linkType: hard
1196411964

11965+
"react-native-monorepo-config@patch:react-native-monorepo-config@npm%3A0.3.1#./.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch::locator=%40livekit%2Freact-native%40workspace%3A.":
11966+
version: 0.3.1
11967+
resolution: "react-native-monorepo-config@patch:react-native-monorepo-config@npm%3A0.3.1#./.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch::version=0.3.1&hash=3eeab5&locator=%40livekit%2Freact-native%40workspace%3A."
11968+
dependencies:
11969+
escape-string-regexp: ^5.0.0
11970+
fast-glob: ^3.3.3
11971+
checksum: b08994dbe97f4a33f1ff317df7bc0415e9779678d751662633ebb6f3a6fb8675802596c82b87635f0f37b8584648ed7d3faaba47a12d851d6a6009123672c02e
11972+
languageName: node
11973+
linkType: hard
11974+
1196511975
"react-native-safe-area-context@npm:^5.5.2":
1196611976
version: 5.6.1
1196711977
resolution: "react-native-safe-area-context@npm:5.6.1"

0 commit comments

Comments
 (0)