Kudo / react-native-v8

Opt-in V8 runtime for React Native Android
MIT License
924 stars 69 forks source link

fix gradle $projectDir in patch for building with forked RN source #44

Closed zxcpoiu closed 4 years ago

zxcpoiu commented 4 years ago

Motivation

The $projectDir for prebuilding v8 RN on the local machine is located at /path/to/react-native-v8/build/ReactAndroid.

This project is prebuilding V8 version of RN and publish to npm. The ReactAndroid path may located at /path/to/react-native-v8/build/ReactAndroid And the v8-android is installed at /path/to/react-native-v8/node_modules/v8-android

But for users who have forked RN source and with this v8 patch, it builds ReactAndroid AAR manually. The ReactAndroid path may located at /path/to/app/node_modules/react-native/ReactAndroid And the v8-android is installed at /path/to/app/node_modules/v8-android

Fix

This PR assumes $projectDir is /path/to/react-native-v8/build/ReactAndroid as it is now, if the dir does not exist, fallback to /path/to/app/node_modules/react-native/ReactAndroid

No breaking changes.

Fix 2 ( updated )

Use findNodeModulePath introduced since RN 62, which is is a better algo to solve this.

Kudo commented 4 years ago

Hey, thank you for the contribution. The change looks good to me. Just a Nit: If the environment is in yarn workspace and package be hoisted, the path might be different. Upstream build.gradle has a better solution - the findNodeModulePath. Do you mind to revise to use findNodeModulePath?

zxcpoiu commented 4 years ago

Sure!

I was testing on 0.61, so missed the findNodeModulePath part Thanks for pointed out. Updated.

Kudo commented 4 years ago

Thank you @zxcpoiu. That's awesome  🔥 and I am going to merge this.