diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..c004e356 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v22.20.0 diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch b/.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch new file mode 100644 index 00000000..5350643d --- /dev/null +++ b/.yarn/patches/react-native-monorepo-config-npm-0.3.1-2343b725c3.patch @@ -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 diff --git a/example/.watchmanconfig b/example/.watchmanconfig new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/example/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/package.json b/package.json index e1a2733d..e225e94f 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/yarn.lock b/yarn.lock index ee1e2083..a005d45c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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: @@ -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"