From 4a925c43c237bf90e15cf5e7d4b5bb9410a0b3cd Mon Sep 17 00:00:00 2001 From: Ryan Schoppmeyer Date: Tue, 7 Mar 2023 06:33:14 -0800 Subject: [PATCH] Support HermesAPILeanOrFull in react native apps (#36202) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36202 This changes all of the in-built dependencies in react native app components upon hermes from HermesAPI to HermesAPIFullOrLean. HermesAPI (full) includes the bytecode compiler and thus has support for eval(). HermesAPILean does not include the bytecode compiler. It throws at runtime if eval is called. The native dependencies are significantly smaller without the bytecode compiler. The HermesAPIFullOrLean target toggles between full and lean modes based on the value of buckconfig field `hermes.lean_vm` (default is false). Therefore, without overriding this config option, this change is a no-op and should result in react native apps being built with exactly the same dependencies as before. If you do specify it, you lose eval support at runtime and gain an apk size savings of a few hundred kB after compression. This also removes the vestigial `hermes_api_dep()` build macro. skip-frl-buck-targeting Reviewed By: javache Differential Revision: D43283200 fbshipit-source-id: 0157be4a9339f70e73d29d694c18b31805107000 --- ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK | 2 +- ReactCommon/hermes/inspector/BUCK | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK b/ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK index f2c0e6ef2ef..6f89b5bc91c 100644 --- a/ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK +++ b/ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK @@ -22,6 +22,6 @@ rn_xplat_cxx_library( deps = [ react_native_target("jni/react/jni:jni"), FBJNI_TARGET, - react_native_xplat_dep("hermes/API:HermesAPI"), + react_native_xplat_dep("hermes/API:HermesAPIFullOrLean"), ], ) diff --git a/ReactCommon/hermes/inspector/BUCK b/ReactCommon/hermes/inspector/BUCK index 53bbdb2d023..0cb887883b2 100644 --- a/ReactCommon/hermes/inspector/BUCK +++ b/ReactCommon/hermes/inspector/BUCK @@ -62,7 +62,7 @@ fb_xplat_cxx_library( ":inspectorlib", "//third-party/glog:glog", "//xplat/folly:futures", - "//xplat/hermes/API:HermesAPI", + "//xplat/hermes/API:HermesAPIFullOrLean", "//xplat/jsi:JSIDynamic", "//xplat/jsi:jsi", ], @@ -164,7 +164,7 @@ fb_xplat_cxx_binary( deps = [ ":chrome", ":inspectorlib", - "//xplat/hermes/API:HermesAPI", + "//xplat/hermes/API:HermesAPIFullOrLean", ], ) @@ -203,7 +203,7 @@ fb_xplat_cxx_library( ":detail", "//third-party/glog:glog", "//xplat/folly:futures", - "//xplat/hermes/API:HermesAPI", + "//xplat/hermes/API:HermesAPIFullOrLean", "//xplat/jsi:jsi", ], )