Skip to content

Commit b4b909c

Browse files
authored
Use node resolver to locate React Native package (#3093)
## Description See software-mansion/react-native-reanimated#6482, Expensify/react-native-live-markdown#472 ## Test plan Build the example app on Android
1 parent a64f74a commit b4b909c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

android/build.gradle

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,10 @@ def resolveReactNativeDirectory() {
3333
return file(reactNativeLocation)
3434
}
3535

36-
// monorepo workaround
37-
// react-native can be hoisted or in project's own node_modules
38-
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
39-
if (reactNativeFromProjectNodeModules.exists()) {
40-
return reactNativeFromProjectNodeModules
41-
}
42-
43-
def reactNativeFromNodeModulesWithReanimated = file("${projectDir}/../../react-native")
44-
if (reactNativeFromNodeModulesWithReanimated.exists()) {
45-
return reactNativeFromNodeModulesWithReanimated
36+
// Fallback to node resolver for custom directory structures like monorepos.
37+
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
38+
if (reactNativePackage.exists()) {
39+
return reactNativePackage.parentFile
4640
}
4741

4842
throw new Exception(

0 commit comments

Comments
 (0)