Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.20.0
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/index.js b/index.js
index 4dc070a2a6ca0ef3fe4e929509f9d9108debd643..f66a3359800b6720ef848d8b76783ff5d3dfd7e7 100644
--- a/index.js
+++ b/index.js
@@ -133,14 +133,6 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
(m, i, self) => self.lastIndexOf(m) === i // Remove duplicates
);

- // We need to exclude the peerDependencies we've collected in packages' node_modules
- // Otherwise duplicate versions of the same package will be loaded
- const blockList = Object.values(packages).flatMap((dir) =>
- peers.map(
- (m) => new RegExp(`^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`)
- )
- );
-
// When we import a package from the monorepo, metro may not be able to find the deps in blockList
// We need to specify them in `extraNodeModules` to tell metro where to find them
const extraNodeModules = peers.reduce((acc, name) => {
@@ -153,6 +145,20 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
return acc;
}, {});

+ // We need to exclude the peerDependencies we've collected in packages' node_modules
+ // Otherwise duplicate versions of the same package will be loaded
+ const blockList = Object.values(packages).flatMap((dir) =>
+ peers.map((m) => {
+ // Skip blocking items that we've specified in extraNodeModules
+ const peerPath = path.join(dir, 'node_modules', m)
+ if(extraNodeModules[m] === peerPath) {
+ return null;
+ }
+ return new RegExp(`^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`)
+ }
+ )
+ ).filter((value) => value != null);
+
// If monorepo root is a package, add it to extraNodeModules so metro can find it
// Normally monorepo packages are symlinked to node_modules, but the root is not
// So we need to add it manually
1 change: 1 addition & 0 deletions example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,8 @@
}
]
]
},
"resolutions": {
"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"
}
}
12 changes: 11 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11952,7 +11952,7 @@ __metadata:
languageName: node
linkType: hard

"react-native-monorepo-config@npm:^0.3.1":
"react-native-monorepo-config@npm:0.3.1":
version: 0.3.1
resolution: "react-native-monorepo-config@npm:0.3.1"
dependencies:
Expand All @@ -11962,6 +11962,16 @@ __metadata:
languageName: node
linkType: hard

"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.":
version: 0.3.1
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."
dependencies:
escape-string-regexp: ^5.0.0
fast-glob: ^3.3.3
checksum: b08994dbe97f4a33f1ff317df7bc0415e9779678d751662633ebb6f3a6fb8675802596c82b87635f0f37b8584648ed7d3faaba47a12d851d6a6009123672c02e
languageName: node
linkType: hard

"react-native-safe-area-context@npm:^5.5.2":
version: 5.6.1
resolution: "react-native-safe-area-context@npm:5.6.1"
Expand Down
Loading