From 4416de35f76e3cecf36879526108f4028e5eaad3 Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Wed, 4 Oct 2023 11:14:59 -0700 Subject: [PATCH] Upgrade xplat/js + arvr/js to hermes-parser 0.16.0 (#39791) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39791 Bump `hermes-parser` packages to the latest released version. Changelog: https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md Notable changes: - Upgraded to the lastest version of emscripten for the parser. - The babel interop logic now more closely matches babel's AST. - The biggest change is we now add the `extra.raw` properties to literal nodes, which results in Babel more closely outputting literal sources. e.g. previously the following would happen `1.0` -> `1`, `'foo'` -> `"foo"` and `1n` -> `1` but now the raw source value is preserved. - Upgraded `prettier-plugin-hermes-parser` to use the latest prettier formatting logic, which causes some minor formatting changes. - `hermes-parser` no longer fails when the `component` name is used within a function type, e.g. `type Foo = (component: string) => void`. Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D49838842 fbshipit-source-id: ebfd2f89852d1bd3b1671ce77f58240d7e17cfbb --- package.json | 6 +- .../package.json | 2 +- .../src/index.js | 5 +- yarn.lock | 78 +++++++++---------- 4 files changed, 46 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 295bc1689f7b7e..ed0f37c8721bf5 100644 --- a/package.json +++ b/package.json @@ -83,10 +83,10 @@ "eslint-plugin-react-native": "^4.0.0", "eslint-plugin-redundant-undefined": "^0.4.0", "eslint-plugin-relay": "^1.8.3", - "flow-api-translator": "0.15.0", + "flow-api-translator": "0.16.0", "flow-bin": "^0.217.2", "glob": "^7.1.1", - "hermes-eslint": "0.15.0", + "hermes-eslint": "0.16.0", "inquirer": "^7.1.0", "jest": "^29.6.3", "jest-junit": "^10.0.0", @@ -98,7 +98,7 @@ "mock-fs": "^5.1.4", "nullthrows": "^1.1.1", "prettier": "2.8.8", - "prettier-plugin-hermes-parser": "0.14.0", + "prettier-plugin-hermes-parser": "0.16.0", "react": "18.2.0", "react-test-renderer": "18.2.0", "rimraf": "^3.0.2", diff --git a/packages/react-native-babel-transformer/package.json b/packages/react-native-babel-transformer/package.json index 0862b76d176fb1..884eca256b1cd5 100644 --- a/packages/react-native-babel-transformer/package.json +++ b/packages/react-native-babel-transformer/package.json @@ -17,7 +17,7 @@ "dependencies": { "@babel/core": "^7.20.0", "@react-native/babel-preset": "*", - "hermes-parser": "0.15.0", + "hermes-parser": "0.16.0", "nullthrows": "^1.1.1" }, "peerDependencies": { diff --git a/packages/react-native-babel-transformer/src/index.js b/packages/react-native-babel-transformer/src/index.js index 8cc90237895473..80ed9cafba8559 100644 --- a/packages/react-native-babel-transformer/src/index.js +++ b/packages/react-native-babel-transformer/src/index.js @@ -202,12 +202,13 @@ const transform /*: BabelTransformer['transform'] */ = ({ // You get this behavior by default when using Babel's `transform` method directly. cloneInputAst: false, }; - const sourceAst = + const sourceAst /*: BabelNodeFile */ = isTypeScriptSource(filename) || isTSXSource(filename) || !options.hermesParser ? parseSync(src, babelConfig) - : require('hermes-parser').parse(src, { + : // $FlowFixMe[incompatible-exact] + require('hermes-parser').parse(src, { babel: true, sourceType: babelConfig.sourceType, }); diff --git a/yarn.lock b/yarn.lock index 581b7913f5b508..300e776a7c75af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5025,18 +5025,18 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561" integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA== -flow-api-translator@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/flow-api-translator/-/flow-api-translator-0.15.0.tgz#3df5af2d45630251f12782679271dc2533bcf094" - integrity sha512-cH5Fo08kQO0vucJfcQqMAPc2De8ooVX/9AhBUiRDhe+Ob98HOSBJamaiFLgTmC9UVnSyIFRKgpG+RRopHWtjwg== +flow-api-translator@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/flow-api-translator/-/flow-api-translator-0.16.0.tgz#c1f9a23ccf756d0b7cc7d168da1dc4203ee4fdc0" + integrity sha512-wIaR2K/NfIa9YllPHO2m6TQPabMFFL8u08ix+aohul0F23+sTQyePGtqOuqWGm63E16sBgh/uPYcsw+/xZoFWA== dependencies: "@babel/code-frame" "^7.16.0" "@typescript-eslint/visitor-keys" "^5.42.0" flow-enums-runtime "^0.0.6" - hermes-eslint "0.15.0" - hermes-estree "0.15.0" - hermes-parser "0.15.0" - hermes-transform "0.15.0" + hermes-eslint "0.16.0" + hermes-estree "0.16.0" + hermes-parser "0.16.0" + hermes-transform "0.16.0" flow-bin@^0.217.2: version "0.217.2" @@ -5420,31 +5420,24 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -hermes-eslint@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/hermes-eslint/-/hermes-eslint-0.15.0.tgz#4d7495cb5e0e9275a1fb0b465b88fccf0b6d8840" - integrity sha512-Rd12uW9FZdOTDDwpVdYUxZGEApskUzBfKYy9RMtczm2uprX8yviPb9QVSVn2hl+xuRTA7Z0FnqDwOwXGiinsRQ== +hermes-eslint@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/hermes-eslint/-/hermes-eslint-0.16.0.tgz#f377e7e0260c82d687f4efedff4ae1a4a193359f" + integrity sha512-8EFCiVY5Sv7fYaje31HgaUIpe5DrRlx8luQ6Cgj9wyVpNpSMoVeoXHsWS2MEA4CHuWKItM1mACB5E4snBQxV/g== dependencies: esrecurse "^4.3.0" - hermes-estree "0.15.0" - hermes-parser "0.15.0" - -hermes-estree@0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.14.0.tgz#c663eea1400980802283338a09d0087c448729e7" - integrity sha512-L6M67+0/eSEbt6Ha2XOBFXL++7MR34EOJMgm+j7YCaI4L/jZqrVAg6zYQKzbs1ZCFDLvEQpOgLlapTX4gpFriA== + hermes-estree "0.16.0" + hermes-parser "0.16.0" hermes-estree@0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.15.0.tgz#e32f6210ab18c7b705bdcb375f7700f2db15d6ba" integrity sha512-lLYvAd+6BnOqWdnNbP/Q8xfl8LOGw4wVjfrNd9Gt8eoFzhNBRVD95n4l2ksfMVOoxuVyegs85g83KS9QOsxbVQ== -hermes-parser@0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.14.0.tgz#edb2e7172fce996d2c8bbba250d140b70cc1aaaf" - integrity sha512-pt+8uRiJhVlErY3fiXB3gKhZ72RxM6E1xRMpvfZ5n6Z5TQKQQXKorgRCRzoe02mmvLKBJFP5nPDGv75MWAgCTw== - dependencies: - hermes-estree "0.14.0" +hermes-estree@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.16.0.tgz#e2c76a1e9d5a4d620790b9fe05fb01f2d53da07d" + integrity sha512-XCoTuBU8S+Jg8nFzaqgy6pNEYo0WYkbMmuJldb3svzpJ2SNUYJDg28b1ltoDMo7k3YlJwPRg7ZS3JTWV3DkDZA== hermes-parser@0.15.0: version "0.15.0" @@ -5453,6 +5446,13 @@ hermes-parser@0.15.0: dependencies: hermes-estree "0.15.0" +hermes-parser@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.16.0.tgz#92d0a34ff4f9b7ffcb04511dfed0cc19df5038e0" + integrity sha512-tdJJntb45DUpv8j7ybHfq8NfIQgz8AgaD+PVFyfjK+O+v2N5zbsSDtlvQN2uxCghoTkQL86BEs9oi8IPrUE9Pg== + dependencies: + hermes-estree "0.16.0" + hermes-profile-transformer@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/hermes-profile-transformer/-/hermes-profile-transformer-0.0.6.tgz#bd0f5ecceda80dd0ddaae443469ab26fb38fc27b" @@ -5460,17 +5460,17 @@ hermes-profile-transformer@^0.0.6: dependencies: source-map "^0.7.3" -hermes-transform@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/hermes-transform/-/hermes-transform-0.15.0.tgz#5509cf6993abafbdc32528098d287f5c91eef52c" - integrity sha512-ACGdssuE2mcu/qSwSfie1yWQs5IBRYy7yokPbdCkHd4M0jPqCiQbwrlRzQP0+XgyZPooINXWHxkhsI5Iffhppw== +hermes-transform@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/hermes-transform/-/hermes-transform-0.16.0.tgz#f2ba027f558d5c59398f807683ade66adda37b69" + integrity sha512-8jckjt5WG+k/zIFSFe1VyTn4xnAJy9Hdej1/9vx0LUEwHXqCwHSasatwuZiF3oKjXX+q92lc33Nrpv1Ixl1gBw== dependencies: "@babel/code-frame" "^7.16.0" esquery "^1.4.0" flow-enums-runtime "^0.0.6" - hermes-eslint "0.15.0" - hermes-estree "0.15.0" - hermes-parser "0.15.0" + hermes-eslint "0.16.0" + hermes-estree "0.16.0" + hermes-parser "0.16.0" homedir-polyfill@^1.0.0, homedir-polyfill@^1.0.1: version "1.0.3" @@ -7756,14 +7756,14 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier-plugin-hermes-parser@0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/prettier-plugin-hermes-parser/-/prettier-plugin-hermes-parser-0.14.0.tgz#1b5122c14b949bfae96541bbeb39cdd15962a072" - integrity sha512-L3QtrNCVYUhN56oAvlkSYnwdOPgYxjBo1Fg+ApXTFUSk+b3uKcMlUqo6j0WZk4QKYtTtDwZcTT1Zl9VIF/7nDg== +prettier-plugin-hermes-parser@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/prettier-plugin-hermes-parser/-/prettier-plugin-hermes-parser-0.16.0.tgz#4393d43a4a6f4ed976493dccbbb93f62c44215c3" + integrity sha512-J4HdSmlxf3a0nVHVi0G6JJJ7sDVtSb5a+QR52LpiQonpQzMkqgIqyCg+Gt1sGMTJqn19Z0yTHxwCmUicVYXUVg== dependencies: - hermes-estree "0.14.0" - hermes-parser "0.14.0" - prettier-plugin-hermes-parser "0.14.0" + hermes-estree "0.16.0" + hermes-parser "0.16.0" + prettier-plugin-hermes-parser "0.16.0" prettier@2.8.8: version "2.8.8"