Skip to content

Commit 8200f91

Browse files
cortinicofacebook-github-bot
authored andcommitted
Disable prefab publishing if REACT_NATIVE_HERMES_SKIP_PREFAB is set. (#33439)
Summary: Pull Request resolved: #33439 This allows us to toggle the publishing of prefab if the `REACT_NATIVE_HERMES_SKIP_PREFAB` env variable is set. With this we can control how big is the .aar of hermes-engine, reducing the size from ~200Mb right now to 8Mb. Changelog: [Internal] [Changed] - Disable prefab publishing if REACT_NATIVE_HERMES_SKIP_PREFAB is set Reviewed By: ShikaSD Differential Revision: D34929265 fbshipit-source-id: eb710b72ee4e17ac04c2924ffdac7a542928e9f8
1 parent b2454f9 commit 8200f91

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

ReactAndroid/build.gradle

+1-7
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ final def extractNativeDependencies = tasks.register('extractNativeDependencies'
249249

250250
task installArchives {
251251
dependsOn("publishReleasePublicationToNpmRepository")
252-
dependsOn(":ReactAndroid:hermes-engine:installArchives")
253252
}
254253

255254
// Creating sources with comments
@@ -374,12 +373,7 @@ dependencies {
374373

375374
// It's up to the consumer to decide if hermes should be included or not.
376375
// Therefore hermes-engine is a compileOnly dependency.
377-
// Moreover, you can toggle where to get the dependency with `buildHermesFromSource`.
378-
if (project.getProperties().getOrDefault("buildHermesFromSource", "false").toBoolean()) {
379-
compileOnly(project(":ReactAndroid:hermes-engine"))
380-
} else {
381-
compileOnly("com.facebook.react:hermes-engine:${VERSION_NAME}")
382-
}
376+
compileOnly(project(":ReactAndroid:hermes-engine"))
383377

384378
javadocDeps("com.squareup:javapoet:1.13.0")
385379

ReactAndroid/hermes-engine/build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ if (hermesVersionFile.exists()) {
2929
def ndkBuildJobs = Runtime.runtime.availableProcessors().toString()
3030
def prefabHeadersDir = new File("$buildDir/prefab-headers")
3131

32+
// By setting REACT_NATIVE_HERMES_SKIP_PREFAB you can skip prefab publishing, to
33+
// reduce the size of the Hermes published .AAR.
34+
def skipPrefabPublishing = System.getenv("REACT_NATIVE_HERMES_SKIP_PREFAB") != null
35+
3236
// We inject the JSI directory used inside the Hermes build with the -DJSI_DIR config.
3337
def jsiDir = rootProject.file("ReactCommon/jsi")
3438

@@ -171,6 +175,7 @@ android {
171175

172176
buildFeatures {
173177
prefab true
178+
prefabPublishing !skipPrefabPublishing
174179
}
175180

176181
dependencies {
@@ -194,10 +199,6 @@ android {
194199
}
195200
}
196201

197-
buildFeatures {
198-
prefabPublishing true
199-
}
200-
201202
prefab {
202203
libhermes {
203204
headers prefabHeadersDir.absolutePath

gradle.properties

-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,3 @@ kotlin_version=1.6.10
1111
# You can also override it from the CLI using
1212
# ./gradlew <task> -PreactNativeArchitectures=x86_64
1313
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
14-
15-
# Use this property if hermes should be built from source or not.
16-
# If set to true, ReactAndroid will depend on :packages:hermes-engine and will build it from source.
17-
# If set to false, ReactAndroid will depend a hermes .aar which should be placed inside ./android folder.
18-
buildHermesFromSource=true

scripts/publish-npm.js

100644100755
+8-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* * or otherwise `{major}.{minor}-stable`
3232
*/
3333

34-
const {exec, echo, exit, test} = require('shelljs');
34+
const {exec, echo, exit, test, env} = require('shelljs');
3535
const {parseVersion, isTaggedLatest} = require('./version-utils');
3636
const fs = require('fs');
3737
const os = require('os');
@@ -176,6 +176,13 @@ if (exec('./gradlew :ReactAndroid:installArchives').code) {
176176
exit(1);
177177
}
178178

179+
// -------- Generating the Hermes Engine Artifacts
180+
env.REACT_NATIVE_HERMES_SKIP_PREFAB = true;
181+
if (exec('./gradlew :ReactAndroid:hermes-engine:installArchives').code) {
182+
echo('Could not generate artifacts');
183+
exit(1);
184+
}
185+
179186
// undo uncommenting javadoc setting
180187
exec('git checkout ReactAndroid/gradle.properties');
181188

0 commit comments

Comments
 (0)