https://github.com/keybase/react-native-v8
Holder for react-native-v8 aars
https://github.com/keybase/react-native-v8
Last synced: 3 months ago
JSON representation
Holder for react-native-v8 aars
- Host: GitHub
- URL: https://github.com/keybase/react-native-v8
- Owner: keybase
- License: mit
- Created: 2019-10-17T18:41:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T03:24:23.000Z (about 6 years ago)
- Last Synced: 2025-01-02T01:25:43.544Z (over 1 year ago)
- Size: 260 MB
- Stars: 2
- Watchers: 11
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/react-native-v8)
[](https://circleci.com/gh/Kudo/react-native-v8)
# React Native with V8 Runtime
The aim of this project is to support V8 runtime for React Native. Designed as opt-in package, it should easy to integrate with existing React Native projects.
## Integration with React Native
To make RN integration easier, we publish prebuilt AAR into [npm](https://www.npmjs.com/package/react-native-v8).
The versioning is aligned with React Native but suffixed with a `-patch.N` in version
E.g.
If your React Native version is `0.60.0`, you should use react-native-v8 `>=0.60.0-patch.0 <0.60.1`.
Following steps will take 0.60.0 as example.
1. Install react-native-v8
```sh
yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'
# [OPTIONAL] If to use different V8 version
# yarn add 'v8-android@7.5.0'
```
2. Modify your React Native build.gradle
```diff
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -161,11 +161,18 @@ android {
}
}
}
+
+ packagingOptions {
+ // Make sure libjsc.so does not packed in APK
+ exclude "**/libjsc.so"
+ }
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
+ // Add v8-android - prebuilt libv8.so into APK
+ implementation 'org.chromium:v8-android:+'
// JSC from node_modules
if (useIntlJsc) {
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -24,8 +24,12 @@ allprojects {
repositories {
mavenLocal()
maven {
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
- url("$rootDir/../node_modules/react-native/android")
+ // Replace AAR from original RN with AAR from react-native-v8
+ url("$rootDir/../node_modules/react-native-v8/dist")
+ }
+ maven {
+ // prebuilt libv8.so
+ url("$rootDir/../node_modules/v8-android/dist")
}
maven {
// Android JSC is installed from npm
```
3. Gradle rebuild or `react-native run-android`
4. Start application and could verify by JS `global._v8runtime().version` which expected to return V8 version.
## Builtin JavaScript object
`global._v8runtime()` has some builtin information such as v8 version.
```js
console.log(`V8 version is ${global._v8runtime().version}`);
```
## V8 Features Flags
V8 provides many feature flags and the most important one should be JIT.
Currently JIT is disabled except on arm64-v8a.
react-native-v8 use the V8 shared libray from [v8-android-buildscripts](https://github.com/Kudo/v8-android-buildscripts).
For detailed V8 features, please check [there](https://github.com/Kudo/v8-android-buildscripts/blob/master/README.md#v8-feature-flags).
## TODO
- [x] Performance comparison with JavaScriptCore in React Native
Please check https://github.com/Kudo/react-native-js-benchmark for the benchmark and result
- [ ] V8 inspector integration
- [ ] V8 snapshot integration
- [ ] V8 code cache experiment