From d2e0f91abbb86a53773754afc3b08f027ecaed67 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 13 Sep 2024 06:11:49 -0700 Subject: [PATCH] Switch to Hermes parser in Jest preset Summary: Resolves https://github.com/facebook/react-native/issues/46355. Changelog: [Internal] Differential Revision: D62583337 --- packages/react-native/jest-preset.js | 6 +++++- packages/react-native/package.json | 1 + yarn.lock | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/react-native/jest-preset.js b/packages/react-native/jest-preset.js index d1a749c5a2701a..5bd9fc56816d23 100644 --- a/packages/react-native/jest-preset.js +++ b/packages/react-native/jest-preset.js @@ -15,7 +15,11 @@ module.exports = { platforms: ['android', 'ios', 'native'], }, transform: { - '^.+\\.(js|ts|tsx)$': 'babel-jest', + '^.+\\.(js)$': [ + 'babel-jest', + {plugins: ['babel-plugin-syntax-hermes-parser']}, + ], + '^.+\\.(ts|tsx)$': 'babel-jest', '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( './jest/assetFileTransformer.js', ), diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 673d7724263345..bd1af9b82c5860 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -119,6 +119,7 @@ "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", + "babel-plugin-syntax-hermes-parser": "^0.23.1", "base64-js": "^1.5.1", "chalk": "^4.0.0", "commander": "^12.0.0", diff --git a/yarn.lock b/yarn.lock index e60999074fcea8..26e760527b2d61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2810,7 +2810,7 @@ babel-plugin-syntax-hermes-parser@0.23.0: dependencies: hermes-parser "0.23.0" -babel-plugin-syntax-hermes-parser@0.23.1: +babel-plugin-syntax-hermes-parser@0.23.1, babel-plugin-syntax-hermes-parser@^0.23.1: version "0.23.1" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-hermes-parser/-/babel-plugin-syntax-hermes-parser-0.23.1.tgz#470e9d1d30ad670d4c8a37138e22ae39c843d1ff" integrity sha512-uNLD0tk2tLUjGFdmCk+u/3FEw2o+BAwW4g+z2QVlxJrzZYOOPADroEcNtTPt5lNiScctaUmnsTkVEnOwZUOLhA== @@ -7387,11 +7387,26 @@ react-devtools-core@^5.3.1: shell-quote "^1.6.1" ws "^7" -react-is@19.0.0-rc-fb9a90fa48-20240614, react-is@^16.13.1, react-is@^16.8.4, react-is@^17.0.1, react-is@^18.0.0: +react-is@19.0.0-rc-fb9a90fa48-20240614: version "19.0.0-rc-fb9a90fa48-20240614" resolved "https://registry.yarnpkg.com/react-is/-/react-is-19.0.0-rc-fb9a90fa48-20240614.tgz#6987893799abdedf2e9929e31541cb6d7dc8285a" integrity sha512-60qI7v1B9RhmZwjTCnAgzcuABOQsIH20vTbETQPaze96s1lY2lSawv9dvXAfF8Z1MIqOppWSKLNOshF0WsZ3OA== +react-is@^16.13.1, react-is@^16.8.4: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + +react-is@^17.0.1: + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" + integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== + +react-is@^18.0.0: + version "18.3.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" + integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== + react-refresh@^0.14.0: version "0.14.2" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.2.tgz#3833da01ce32da470f1f936b9d477da5c7028bf9"