diff --git a/gradle.properties b/gradle.properties index f494dd4fe8c1d7..d7c39175371a63 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ react.internal.useHermesStable=false react.internal.useHermesNightly=true # Controls whether to use Hermes 1.0. Clean and rebuild when changing. -hermesV1Enabled=false +hermesV1Enabled=true diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt index 2285d3fac00dc2..26174c0ce0de01 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt @@ -59,5 +59,5 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) { val codegenDir: DirectoryProperty = objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen")) - val hermesV1Enabled: Property = objects.property(Boolean::class.java).convention(false) + val hermesV1Enabled: Property = objects.property(Boolean::class.java).convention(true) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index f93ef2c9c144fb..756e6f3f29c5d2 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -113,7 +113,7 @@ internal object DependencyUtils { fun configureDependencies( project: Project, coordinates: Coordinates, - hermesV1Enabled: Boolean = false, + hermesV1Enabled: Boolean = true, ) { if ( coordinates.versionString.isBlank() || @@ -149,7 +149,7 @@ internal object DependencyUtils { internal fun getDependencySubstitutions( coordinates: Coordinates, - hermesV1Enabled: Boolean = false, + hermesV1Enabled: Boolean = true, ): List> { val dependencySubstitution = mutableListOf>() val hermesVersion = diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt index f6a147426f1c31..136a7e1bdb9ae7 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt @@ -29,6 +29,8 @@ internal object ProjectUtils { const val HERMES_FALLBACK = true + const val HERMES_V1_ENABLED_FALLBACK = true + internal fun Project.isNewArchEnabled(): Boolean = true internal val Project.isHermesEnabled: Boolean @@ -73,6 +75,7 @@ internal object ProjectUtils { internal val Project.isHermesV1Enabled: Boolean get() = + if (project.hasProperty(HERMES_V1_ENABLED) || project.hasProperty(SCOPED_HERMES_V1_ENABLED)) { (project.hasProperty(HERMES_V1_ENABLED) && project.property(HERMES_V1_ENABLED).toString().toBoolean()) || (project.hasProperty(SCOPED_HERMES_V1_ENABLED) && @@ -81,6 +84,9 @@ internal object ProjectUtils { project.extraProperties.get(HERMES_V1_ENABLED).toString().toBoolean()) || (project.extraProperties.has(SCOPED_HERMES_V1_ENABLED) && project.extraProperties.get(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) + } else { + HERMES_V1_ENABLED_FALLBACK + } internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean { val parsedPackageJson = readPackageJsonFile(this, rootProperty) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index b48ea7984633a9..9915dd32bd56a5 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -290,6 +290,8 @@ class DependencyUtilsTest { assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) + .isFalse() + assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() } @@ -325,10 +327,14 @@ class DependencyUtilsTest { assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) + .isFalse() + assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) + .isFalse() + assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() } @@ -384,12 +390,20 @@ class DependencyUtilsTest { assertThat( appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } ) + .isFalse() + assertThat( + appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } + ) .isTrue() assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) .isTrue() assertThat( libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } ) + .isFalse() + assertThat( + libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } + ) .isTrue() } @@ -430,7 +444,7 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withClassicHermes() { + fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withHermesV1() { val dependencySubstitutions = getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0")) @@ -442,7 +456,7 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.hermes:hermes-android:0.42.0") + assertThat("com.facebook.hermes:hermes-android:0.43.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." @@ -451,11 +465,11 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withDefaultGroupAndFallback_substitutesCorrectly_withClassicHermes() { val dependencySubstitutions = getDependencySubstitutions( DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0"), - hermesV1Enabled = true, + hermesV1Enabled = false, ) assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) @@ -466,7 +480,7 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.hermes:hermes-android:0.43.0") + assertThat("com.facebook.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." @@ -475,7 +489,7 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withClassicHermes() { + fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withHermesV1() { val dependencySubstitutions = getDependencySubstitutions( DependencyUtils.Coordinates( @@ -494,14 +508,14 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") + assertThat("io.github.test.hermes:hermes-android:0.43.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." ) .isEqualTo(dependencySubstitutions[1].third) assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") + assertThat("io.github.test.hermes:hermes-android:0.43.0") .isEqualTo(dependencySubstitutions[2].second) assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") .isEqualTo(dependencySubstitutions[2].third) @@ -510,14 +524,14 @@ class DependencyUtilsTest { assertThat("The react-android dependency was modified to use the correct Maven group.") .isEqualTo(dependencySubstitutions[3].third) assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") + assertThat("io.github.test.hermes:hermes-android:0.43.0") .isEqualTo(dependencySubstitutions[4].second) assertThat("The hermes-android dependency was modified to use the correct Maven group.") .isEqualTo(dependencySubstitutions[4].third) } @Test - fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withCustomGroupAndFallbackToClassicHermes_substitutesCorrectly_withClassicHermes() { val dependencySubstitutions = getDependencySubstitutions( DependencyUtils.Coordinates( @@ -527,7 +541,7 @@ class DependencyUtilsTest { "io.github.test", "io.github.test.hermes", ), - hermesV1Enabled = true, + hermesV1Enabled = false, ) assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) @@ -537,14 +551,14 @@ class DependencyUtilsTest { ) .isEqualTo(dependencySubstitutions[0].third) assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") + assertThat("io.github.test.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[1].second) assertThat( "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." ) .isEqualTo(dependencySubstitutions[1].third) assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") + assertThat("io.github.test.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[2].second) assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") .isEqualTo(dependencySubstitutions[2].third) @@ -553,7 +567,7 @@ class DependencyUtilsTest { assertThat("The react-android dependency was modified to use the correct Maven group.") .isEqualTo(dependencySubstitutions[3].third) assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) - assertThat("io.github.test.hermes:hermes-android:0.43.0") + assertThat("io.github.test.hermes:hermes-android:0.42.0") .isEqualTo(dependencySubstitutions[4].second) assertThat("The hermes-android dependency was modified to use the correct Maven group.") .isEqualTo(dependencySubstitutions[4].third) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt index a22933e6aacafb..f4ec2a40acf796 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt @@ -117,8 +117,8 @@ class ProjectUtilsTest { } @Test - fun isHermesV1Enabled_returnsFalseByDefault() { - assertThat(createProject().isHermesV1Enabled).isFalse() + fun isHermesV1Enabled_returnsTrueByDefault() { + assertThat(createProject().isHermesV1Enabled).isTrue() } @Test diff --git a/scripts/releases/utils/hermes-utils.js b/scripts/releases/utils/hermes-utils.js index 37b57893663c10..dd067788afb5de 100644 --- a/scripts/releases/utils/hermes-utils.js +++ b/scripts/releases/utils/hermes-utils.js @@ -27,6 +27,7 @@ const MAVEN_VERSIONS_FILE_PATH = path.join( async function getLatestHermesNightlyVersion() /*: Promise<{ compilerVersion: string, + compilerV1Version: string, runtimeVersion: string, runtimeV1Version: string, }> */ { @@ -43,6 +44,7 @@ async function getLatestHermesNightlyVersion() /*: Promise<{ return { compilerVersion, + compilerV1Version, // runtime version should match the compiler version runtimeVersion: compilerVersion, runtimeV1Version: compilerV1Version, @@ -84,7 +86,7 @@ async function updateHermesRuntimeDependenciesVersions( async function updateHermesVersionsToNightly() { const hermesVersions = await getLatestHermesNightlyVersion(); await updateHermesCompilerVersionInDependencies( - hermesVersions.compilerVersion, + hermesVersions.compilerV1Version, ); await updateHermesRuntimeDependenciesVersions( hermesVersions.runtimeVersion,