-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android][gradle] Use Node's module resolution algo to find JSC & Hermes #26773
Conversation
9ac9059
to
0c8cf42
Compare
The Gradle build file looks up jsc-android and hermes-engine using hard-coded paths. Rather than assuming the location of these packages, which are distributed and installed as npm packages, this commit makes the Gradle file use Node's standard module resolution algorithm. It looks up the file hierarchy until it finds a matching npm package or reaches the root directory. Test plan: Ensure that CI tests pass, and that `./gradlew :ReactAndroid:installArchives` works. Printed out the paths that the Gradle script found for jsc-android and hermes-engine (both were `<my stuff>/react-native/node_modules/jsc-android|hermes-engine`).
0c8cf42
to
edd8a81
Compare
Removed the hard-coded edge cases and explained in a comment the various repo structures this new approach automatically handles. Error handling is better too. |
Janic pointed out that the various hard-coded paths used to find npm packages are no longer needed because the general Node module resolution algorithm takes care of those cases. Added comments to `findNodeModulePath` to explain that it handles those cases.
25178f4
to
4ba7809
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice, thank you for the cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @ide in fc25f28. When will my fix make it into a release? | Upcoming Releases |
Summary: DiffTrain build for commit facebook/react@f533cee. Changelog: [Internal] << DO NOT EDIT BELOW THIS LINE >> Reviewed By: christophpurrer Differential Revision: D45540265 Pulled By: tyao1 fbshipit-source-id: 3dd365f0569953075c61f7fdca2eb099f1bf98d7
Summary: DiffTrain build for commit facebook/react@f533cee. Changelog: [Internal] << DO NOT EDIT BELOW THIS LINE >> Reviewed By: christophpurrer Differential Revision: D45540265 Pulled By: tyao1 fbshipit-source-id: 3dd365f0569953075c61f7fdca2eb099f1bf98d7
Summary
The Gradle build file looks up jsc-android and hermes-engine using hard-coded paths. Rather than assuming the location of these packages, which are distributed and installed as npm packages, this commit makes the Gradle file use Node's standard module resolution algorithm. It looks up the file hierarchy until it finds a matching npm package or reaches the root directory.
Changelog
[Android] [Changed] - ReactAndroid's Gradle file uses Node's module resolution algorithm to find JSC & Hermes
Test Plan
Ensure that CI tests pass, and that
./gradlew :ReactAndroid:installArchives
works. Printed out the paths that the Gradle script found for jsc-android and hermes-engine (both were<my stuff>/react-native/node_modules/jsc-android|hermes-engine
).