From ac48b56a1a5d87e88a086137ba64c1eeb571e895 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 11 May 2026 12:55:12 -0700 Subject: [PATCH] Rename try-set-nightly-hermes-compiler.js (#56758) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56758 Rename scripts/try-set-nightly-hermes-compiler.js to scripts/try-set-hermes-compiler-prebuilt.js. The script sets the hermes-compiler version to the latest prebuilt (latest-v1 on npm), not a nightly build. Update the preinstall script reference in the root package.json. ## Changelog: [Internal] - Reviewed By: cortinico Differential Revision: D104649635 fbshipit-source-id: 8375d0518ea8c9ca99a59fd65366210eeea91e50 --- package.json | 2 +- scripts/try-set-hermes-compiler-prebuilt.js | 26 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/try-set-hermes-compiler-prebuilt.js diff --git a/package.json b/package.json index 7081b02b8ea..3cc6232ccbe 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lint-kotlin": "./gradlew ktfmtFormat", "lint-markdown": "markdownlint-cli2 2>&1", "lint": "eslint --max-warnings 0 .", - "preinstall": "node ./scripts/try-set-nightly-hermes-compiler.js", + "preinstall": "node ./scripts/try-set-hermes-compiler-prebuilt.js", "prettier": "prettier --write \"./**/*.{js,md,yml,ts,tsx}\"", "shellcheck": "./.github/workflow-scripts/analyze_scripts.sh", "start": "yarn --cwd packages/rn-tester start", diff --git a/scripts/try-set-hermes-compiler-prebuilt.js b/scripts/try-set-hermes-compiler-prebuilt.js new file mode 100644 index 00000000000..6b3edd0c941 --- /dev/null +++ b/scripts/try-set-hermes-compiler-prebuilt.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// @flow +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + +function main() { + const packageJsonPath = path.join(__dirname, '../packages/react-native/package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + const hermesCompilerVersion = packageJson.dependencies['hermes-compiler']; + + if (hermesCompilerVersion === '0.0.0') { + console.log(`Hermes compiler version not set. Updating to the latest-v1 release.`); + execSync('yarn workspace react-native add hermes-compiler@latest-v1 --exact', { stdio: 'inherit' }); + } else { + console.log(`Hermes compiler version set to ${hermesCompilerVersion}. Not setting hermes.`); + } +} + +main();