Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.73] Make Hermes the default JS engine #12371

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 17 additions & 16 deletions .ado/jobs/cli-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,32 @@ parameters:
platform: x86
projectType: lib
additionalRunArguments: --no-autolink --no-deploy
- Name: X86DebugCppHermes
- Name: X86DebugCppChakra
language: cpp
configuration: Debug
platform: x86
projectType: app
additionalInitArguments: --useHermes
- Name: X64ReleaseCsHermes
useChakra: true
- Name: X64ReleaseCsChakra
language: cs
configuration: Release
platform: x64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
runWack: true
- Name: Arm64ReleaseCsHermes
- Name: Arm64ReleaseCsChakra
language: cs
configuration: Release
platform: ARM64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
additionalRunArguments: --no-deploy
- Name: X64ReleaseCppHermes
- Name: X64ReleaseCppChakra
language: cpp
configuration: Release
platform: x64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
runWack: true
- Name: X86DebugCppNuget
language: cpp
Expand Down Expand Up @@ -224,32 +224,32 @@ parameters:
platform: x86
projectType: lib
additionalRunArguments: --no-autolink --no-deploy
- Name: X86DebugCppHermes
- Name: X86DebugCppChakra
language: cpp
configuration: Debug
platform: x86
projectType: app
additionalInitArguments: --useHermes
- Name: X64ReleaseCsHermes
useChakra: true
- Name: X64ReleaseCsChakra
language: cs
configuration: Release
platform: x64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
runWack: true
- Name: Arm64ReleaseCsHermes
- Name: Arm64ReleaseCsChakra
language: cs
configuration: Release
platform: ARM64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
additionalRunArguments: --no-deploy
- Name: X64ReleaseCppHermes
- Name: X64ReleaseCppChakra
language: cpp
configuration: Release
platform: x64
projectType: app
additionalInitArguments: --useHermes
useChakra: true
runWack: true
- Name: X86DebugCppNuget
language: cpp
Expand Down Expand Up @@ -410,4 +410,5 @@ jobs:
additionalRunArguments: ${{ matrix.additionalRunArguments }}
runWack: ${{ coalesce(matrix.runWack, false) }}
buildEnvironment: ${{ parameters.buildEnvironment }}
useChakra: ${{ coalesce(matrix.useChakra, false) }}
useNuGet: ${{ coalesce(matrix.useNuGet, false) }}
20 changes: 10 additions & 10 deletions .ado/jobs/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ parameters:
Matrix:
- Name: X64Chakra
BuildPlatform: x64
UseHermes: false
UseChakra: true
- Name: X64Hermes
BuildPlatform: x64
UseHermes: true
UseChakra: false
- Name: X86Chakra
BuildPlatform: x86
UseHermes: false
UseChakra: true
- Name: X86Hermes
BuildPlatform: x86
UseHermes: true
UseChakra: false
- BuildEnvironment: Continuous
Matrix:
- Name: X64Chakra
BuildPlatform: x64
UseHermes: false
UseChakra: true
- Name: X64Hermes
BuildPlatform: x64
UseHermes: true
UseChakra: false
- Name: X86Chakra
BuildPlatform: x86
UseHermes: false
UseChakra: true
- Name: X86Hermes
BuildPlatform: x86
UseHermes: true
UseChakra: false

jobs:
- ${{ each config in parameters.buildMatrix }}:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
parameters:
package: packages/e2e-test-app
feature: UseHermes
value: ${{ matrix.UseHermes }}
value: ${{ not(coalesce(matrix.UseChakra, false)) }}

- template: ../templates/run-windows-with-certificates.yml
parameters:
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
- ${{ each config in parameters.buildMatrix }}:
- ${{ if eq(config.BuildEnvironment, parameters.buildEnvironment) }}:
- ${{ each matrix in config.Matrix }}:
- ${{ if eq(matrix.UseHermes, true) }}:
- ${{ if eq(matrix.UseChakra, false) }}:
- job: E2ETestFabric${{ matrix.Name }}
displayName: E2E Test App Fabric ${{ matrix.Name }}

Expand Down
48 changes: 29 additions & 19 deletions .ado/jobs/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,64 @@ parameters:
BuildPlatform: ARM64
BuildConfiguration: Debug
DeployOptions: --no-deploy # We don't have Arm agents
UseHermes: false
- Name: X64WebDebug
BuildPlatform: x64
BuildConfiguration: Debug
DeployOptions:
UseHermes: false
- Name: X64ReleaseHermes
- Name: X86WebDebug
BuildPlatform: x86
BuildConfiguration: Debug
DeployOptions:
- Name: X64Release
BuildPlatform: x64
BuildConfiguration: Release
DeployOptions:
UseHermes: true
- Name: X86WebDebug
- Name: X86Release
BuildPlatform: x86
BuildConfiguration: Debug
BuildConfiguration: Release
DeployOptions:
- Name: X64ReleaseChakra
BuildPlatform: x64
BuildConfiguration: Release
DeployOptions:
UseHermes: false
- Name: X86ReleaseHermes
UseChakra: true
- Name: X86ReleaseChakra
BuildPlatform: x86
BuildConfiguration: Release
DeployOptions:
UseHermes: true
UseChakra: true
- BuildEnvironment: Continuous
Matrix:
- Name: Arm64Debug
BuildPlatform: ARM64
BuildConfiguration: Debug
DeployOptions: --no-deploy # We don't have Arm agents
UseHermes: false
- Name: X64WebDebug
BuildPlatform: x64
BuildConfiguration: Debug
DeployOptions:
UseHermes: false
- Name: X64ReleaseHermes
- Name: X86WebDebug
BuildPlatform: x86
BuildConfiguration: Debug
DeployOptions:
- Name: X64Release
BuildPlatform: x64
BuildConfiguration: Release
DeployOptions:
UseHermes: true
- Name: X86WebDebug
- Name: X86Release
BuildPlatform: x86
BuildConfiguration: Debug
BuildConfiguration: Release
DeployOptions:
- Name: X64ReleaseChakra
BuildPlatform: x64
BuildConfiguration: Release
DeployOptions:
UseHermes: false
- Name: X86ReleaseHermes
UseChakra: true
- Name: X86ReleaseChakra
BuildPlatform: x86
BuildConfiguration: Release
DeployOptions:
UseHermes: true
UseChakra: true

jobs:
- ${{ each config in parameters.buildMatrix }}:
Expand Down Expand Up @@ -101,7 +111,7 @@ jobs:
parameters:
package: packages/integration-test-app
feature: UseHermes
value: ${{ matrix.UseHermes }}
value: ${{ not(coalesce(matrix.UseChakra, false))}}

- ${{ if eq(matrix.BuildConfiguration, 'Debug') }}:
# The build is more likely to crash after we've started other bits that
Expand Down
9 changes: 9 additions & 0 deletions .ado/templates/react-native-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ parameters:
- name: additionalRunArguments
type: string
default: ''
- name: useChakra
type: boolean
default: false
- name: useNuGet
type: boolean
default: false
Expand Down Expand Up @@ -102,6 +105,12 @@ steps:
workingDirectory: $(Agent.BuildDirectory)\testcli
env:
npm_config_registry: http://localhost:4873

- template: set-experimental-feature.yml
parameters:
package: ..\testcli
feature: UseHermes
value: ${{ not(parameters.UseChakra) }}

- ${{ if eq(parameters.projectType, 'app') }}:
- powershell: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[0.73] Make Hermes the default JS engine",
"packageName": "@react-native-windows/cli",
"email": "jthysell@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[0.73] Make Hermes the default JS engine",
"packageName": "react-native-windows",
"email": "jthysell@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,28 @@ export function tryFindPropertyValue(
return null;
}

/**
* Search for the given property in the project contents and return its value.
* @param projectContents The XML project contents.
* @param propertyName The property to look for.
* @return The value of the tag if it exists.
*/
export function tryFindPropertyValueAsBoolean(
projectContents: Node,
propertyName: string,
): boolean | null {
const rawValue = tryFindPropertyValue(projectContents, propertyName);

switch (rawValue) {
case 'true':
return true;
case 'false':
return false;
default:
return null;
}
}

export function findPropertyValue(
projectContents: Node,
propertyName: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import findUp from 'find-up';
import {
readProjectFile,
findPropertyValue,
tryFindPropertyValueAsBoolean,
} from '../commands/config/configUtils';

import {
Expand Down Expand Up @@ -130,6 +131,27 @@ export async function copyProjectTemplateAndReplace(
console.log('Using experimental NuGet dependency.');
}

const experimentalPropsPath = path.join(
destPath,
windowsDir,
'ExperimentalFeatures.props',
);

let existingUseHermes: boolean | null = null;
if (fs.existsSync(experimentalPropsPath)) {
existingUseHermes = tryFindPropertyValueAsBoolean(
readProjectFile(experimentalPropsPath),
'UseHermes',
);
}

if (existingUseHermes === false) {
console.warn(
'Hermes is now the default JS engine and will be enabled for this project. Support for Chakra will be deprecated in the future. To disable Hermes and keep using Chakra for now, see https://microsoft.github.io/react-native-windows/docs/hermes#disabling-hermes.',
);
}
options.useHermes = true;

if (options.useWinUI3) {
throw new CodedError(
'IncompatibleOptions',
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-test-app/windows/ExperimentalFeatures.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Label="Microsoft.ReactNative Experimental Features">
<UseHermes>false</UseHermes>
<UseHermes>true</UseHermes>
<EnableSourceLink>true</EnableSourceLink>
<ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Label="Microsoft.ReactNative Experimental Features">
<UseHermes>false</UseHermes>
<UseHermes>true</UseHermes>
<EnableSourceLink>true</EnableSourceLink>
<ReactExperimentalFeaturesSet>true</ReactExperimentalFeaturesSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @format
*/

// Make sure that we import something from react-native so that we build a complete bundle
// eslint-disable-next-line no-unused-vars
import {View} from 'react-native';

import {default as myTrivialTurboModule} from './NativeMyTrivialTurboModule';

myTrivialTurboModule.startFromJS();
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* @format
*/

// Make sure that we import something from react-native so that we build a complete bundle
// eslint-disable-next-line no-unused-vars
import {View} from 'react-native';

import {default as mySimpleTurboModule} from './NativeMySimpleTurboModuleCxx';

// The logging of the TurboModule functions is verified against the test action sequence.
Expand Down