All Projects → Kudo → React Native V8

Kudo / React Native V8

Licence: mit
Opt-in V8 runtime for React Native Android

Projects that are alternatives of or similar to React Native V8

pdjs
JavaScript External for Pure Data based on V8
Stars: ✭ 45 (-91.25%)
Mutual labels:  v8
Dvm
Deno Version Manager - Easy way to manage multiple active deno versions.
Stars: ✭ 271 (-47.28%)
Mutual labels:  v8
Memeye
👀 The eye of memory. A lightweight memory monitor and dashboard for Node.js application on development.
Stars: ✭ 332 (-35.41%)
Mutual labels:  v8
rust rewrite
A programming environment that aims to help people learn how to program in JavaScript, while giving them a tour on how old computers and their limitations used to be.
Stars: ✭ 26 (-94.94%)
Mutual labels:  v8
Javascriptengineswitcher
JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines (ChakraCore, Jering.Javascript.NodeJS, Jint, Jurassic, MSIE JavaScript Engine for .NET, NiL.JS, Microsoft ClearScript.V8 and VroomJs). This library allows you to quickly and easily switch to using of another JavaScript engine.
Stars: ✭ 265 (-48.44%)
Mutual labels:  v8
Little Javascript Book
Early draft for The Little JavaScript Book
Stars: ✭ 305 (-40.66%)
Mutual labels:  v8
Framework
Advanced modding framework for multiplayer modifications
Stars: ✭ 21 (-95.91%)
Mutual labels:  v8
Deep Into Node
深入理解Node.js:核心思想与源码分析
Stars: ✭ 4,005 (+679.18%)
Mutual labels:  v8
Fibjs
JavaScript on Fiber (built on Chrome's V8 JavaScript engine)
Stars: ✭ 2,880 (+460.31%)
Mutual labels:  v8
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (-37.35%)
Mutual labels:  v8
JustDraw
A Test for Android Canvas Painting with JavaScript Engine
Stars: ✭ 42 (-91.83%)
Mutual labels:  v8
Go V8
Go binding for v8
Stars: ✭ 255 (-50.39%)
Mutual labels:  v8
Webrtc Tutorial
📚 WebRTC 中文教程
Stars: ✭ 305 (-40.66%)
Mutual labels:  v8
object-shape
Get a description of a JS object's shape.
Stars: ✭ 24 (-95.33%)
Mutual labels:  v8
V8eval
Multi-language bindings to JavaScript engine V8
Stars: ✭ 332 (-35.41%)
Mutual labels:  v8
V8Android
A demo APP for embedding V8 engine in Android APP
Stars: ✭ 45 (-91.25%)
Mutual labels:  v8
Web Tooling Benchmark
JavaScript benchmark for common web developer workloads
Stars: ✭ 290 (-43.58%)
Mutual labels:  v8
V8py
Write Python APIs, then call them from JavaScript using the V8 engine.
Stars: ✭ 399 (-22.37%)
Mutual labels:  v8
Javascript Idiosyncrasies
A bunch of Javascript idiosyncrasies to beginners.
Stars: ✭ 353 (-31.32%)
Mutual labels:  v8
V8.js.cn
V8 官方网站中文翻译
Stars: ✭ 308 (-40.08%)
Mutual labels:  v8

npm version CircleCI

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.

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
yarn add '[email protected]>=0.60.0-patch.0 <0.60.1'

# [OPTIONAL] If to use different V8 version
# yarn add '[email protected]'
  1. Modify your React Native build.gradle
--- 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 libv8android.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 libv8android.so
+            url("$rootDir/../node_modules/v8-android/dist")
         }
         maven {
             // Android JSC is installed from npm
  1. Gradle rebuild or react-native run-android

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

console.log(`V8 version is ${global._v8runtime().version}`);

Please note that global._v8runtime() existed only for V8 enabled environment but not React Native remote debugging mode. For remote debugging mode, the JavaScript actually runs on Chrome from your host and there is no V8Runtime.

V8 Features Flags

V8 provides many feature flags and the most important one should be JIT. Currently JIT is disabled for V8 lite mode

react-native-v8 use the V8 shared libray from v8-android-buildscripts. For detailed V8 features, please check there.

You can do the following to use one of these features in place of V8 lite mode which is packaged as the default for this repository:

  1. Add v8-android-jit via yarn or npm
$ npm i v8-android-jit
$ yarn add v8-android-jit
  1. Modify the gradle dependency to use v8-android-jit or other variants
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -29,7 +29,7 @@ allprojects {
         }
         maven {
             // prebuilt libv8android.so
-            url("$rootDir/../node_modules/v8-android/dist")
+            url("$rootDir/../node_modules/v8-android-jit/dist")
         }
         maven {
             // Android JSC is installed from npm

This method can also be used to swap to other variants of V8. All possible variants include:

  • v8-android
  • v8-android-nointl
  • v8-android-jit
  • v8-android-jit-nointl

Simply switch out v8-android-jit in the steps provided with the variant that you would like to use.

iOS Support (Experimented)

We did have experimented iOS support. To adopt V8 for Xcodeproj gets a little complicated, so we have a pre-shaped template. Please check react-native-template-v8 for more information.

FAQ

How to reduce APK size ?

The V8 currently bundled by default supports Intl and the ICU data costs about 7MiB per ABI. If you are not going to use Intl, you could use no-Intl version to reduce APK size. (jsc-android and Hermes have no Intl by default)

TODO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].