Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

ide
Copy link
Contributor

@ide ide commented Oct 9, 2019

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).

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner labels Oct 9, 2019
@ide ide force-pushed the gradle-node-resolution branch from 9ac9059 to 0c8cf42 Compare October 9, 2019 03:12
@react-native-bot react-native-bot added the Platform: Android Android applications. label Oct 9, 2019
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`).
@ide ide force-pushed the gradle-node-resolution branch from 0c8cf42 to edd8a81 Compare October 9, 2019 03:31
ReactAndroid/build.gradle Outdated Show resolved Hide resolved
ReactAndroid/build.gradle Outdated Show resolved Hide resolved
ReactAndroid/build.gradle Show resolved Hide resolved
@ide
Copy link
Contributor Author

ide commented Oct 9, 2019

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.
@ide ide force-pushed the gradle-node-resolution branch from 25178f4 to 4ba7809 Compare October 9, 2019 20:00
Copy link
Contributor

@cpojer cpojer left a 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!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ide in fc25f28.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 14, 2019
@ide ide deleted the gradle-node-resolution branch April 25, 2020 08:29
facebook-github-bot pushed a commit that referenced this pull request May 5, 2023
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
jeongshin pushed a commit to jeongshin/react-native that referenced this pull request May 7, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Expo Partner: Expo Partner Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants