show JSC removal message on Android (#49709)

Summary:
show build time jsc removal warning. https://github.com/facebook/react-native/issues/49692 but for android

![Screenshot 2025-02-27 at 3 41 43 PM](https://github.com/user-attachments/assets/a4fe6d52-5e05-45b0-a403-c71372dfba06)

## Changelog:

[ANDROID] [CHANGED] - Add a build time JSC lean core warning

Pull Request resolved: https://github.com/facebook/react-native/pull/49709

Test Plan: - test on rn-tester. rn-tester has a jsc build variant. it shows the warning anyway. commenting out `enableHermesOnlyInVariants` will suppress the warning.

Reviewed By: rshest

Differential Revision: D70323283

Pulled By: cortinico

fbshipit-source-id: 632a8b9086c5d90d7f14ea705464356a1292bcad
This commit is contained in:
Kudo Chien
2025-02-27 08:38:35 -08:00
committed by Facebook GitHub Bot
parent 13a0b4691a
commit 90e27c2b4f
2 changed files with 26 additions and 0 deletions
@@ -9,6 +9,7 @@ package com.facebook.react
import com.android.build.api.variant.Variant
import com.facebook.react.tasks.BundleHermesCTask
import com.facebook.react.utils.BackwardCompatUtils.showJSCRemovalMessage
import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
import com.facebook.react.utils.NdkConfiguratorUtils.configureJsEnginePackagingOptions
import com.facebook.react.utils.NdkConfiguratorUtils.configureNewArchPackagingOptions
@@ -53,6 +54,9 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
configureNewArchPackagingOptions(project, config, variant)
configureJsEnginePackagingOptions(config, variant, isHermesEnabledInThisVariant, useThirdPartyJSC)
if (!isHermesEnabledInThisVariant && !useThirdPartyJSC) {
showJSCRemovalMessage(project)
}
if (!isDebuggableVariant) {
val entryFileEnvVariable = System.getenv("ENTRY_FILE")
@@ -11,6 +11,7 @@ import java.util.*
import org.gradle.api.Project
internal object BackwardCompatUtils {
private var hasShownJSCRemovalMessage = false
fun configureBackwardCompatibilityReactMap(project: Project) {
if (project.extensions.extraProperties.has("react")) {
@@ -45,4 +46,25 @@ internal object BackwardCompatUtils {
// We set an empty react[] map so if a library is reading it, they will find empty values.
project.extensions.extraProperties.set("react", mapOf<String, String>())
}
fun showJSCRemovalMessage(project: Project) {
if (hasShownJSCRemovalMessage) {
return
}
val message =
"""
=============== JavaScriptCore is being moved ===============
JavaScriptCore has been extracted from react-native core
and will be removed in a future release. It can now be
installed from `@react-native-community/javascriptcore`
See: https://github.com/react-native-community/javascriptcore
=============================================================
"""
.trimIndent()
project.logger.warn(message)
hasShownJSCRemovalMessage = true
}
}