Skip to content

Commit

Permalink
[template] Fix hermes command not found on monorepo (#15154)
Browse files Browse the repository at this point in the history
# Why

when hermes is enabled, react-native uses a fixed path to search hermes related command:
https://github.com/facebook/react-native/blob/6df04ae6668275d8c3231ddf290d72b45a32d2d4/react.gradle#L38-L46
this fixed path breaks monorepo support.


# How

passing node resolved path. since react.gradle will do some normalization and path like `package.json/../%OS-BIN%/hermesc` is not supported. the fix uses a slightly different solution to get the absolute path.

# Test Plan

https://gitlab.com/kudochien/sdkmono
build from `./packages/sdk43`
  • Loading branch information
Kudo committed Nov 11, 2021
1 parent cb0109b commit eb76b7b
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -79,7 +79,9 @@ import com.android.build.OutputFile

project.ext.react = [
enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../cli.js"),
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
]

apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
Expand Down

0 comments on commit eb76b7b

Please sign in to comment.