-
Notifications
You must be signed in to change notification settings - Fork 647
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
@babel/plugin-proposal-decorators
is not supported in hermes-parser
- was: Broken babel preset setup with @babel/plugin-proposal-decorators and React Native 0.76.0
#1549
Comments
@babel/plugin-proposal-decorators
is not supported in hermes-parser
- was: Broken babel preset setup with @babel/plugin-proposal-decorators and React Native 0.76.0
Is that something to be fixed or unsupported? |
Thanks for the issue. We are discussing how to proceed forward internally. We made some changes in the JS parsers and the new one does not support all the Babel plugins, especially the ones that are still in a proposal stage (like the decorators one, which is in stage 3). @lucaswitch would you be able to work around this, for the time being? |
Not at all, actually i had to revert the apps to 0.75.4. We're using that to define schemas on https://github.com/Nozbe/WatermelonDB which is the goto solution for offline first apps on react-native right now. |
@lucaswitch Working on a fix, where we can opt out JS files without Workaround: For now, please convert files that need this extended syntax to TypeScript ( |
Thats awesome! |
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Differential Revision: D65272155
Summary: Motivated by facebook/hermes#1549. This was originally changed in facebook#46696, as our internal Flow support had diverged from `babel/eslint-parser` (facebook#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript or Flow in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses `babel/plugin-syntax-flow` via `babel/eslint-parser` (**this change**). I'd love to simplify this 😅. Switching to `hermes-eslint` for the RN monorepo codebase (D63541483) is unchanged. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D65272156
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Reviewed By: cipolleschi Differential Revision: D65272155
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Reviewed By: robhogan, cipolleschi Differential Revision: D65272155
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Differential Revision: D65272155
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Differential Revision: D65272155
Summary: Pull Request resolved: #47333 Motivated by facebook/hermes#1549. This was originally changed in #46696, as our internal Flow support had diverged from `babel/eslint-parser` (#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript or Flow in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses `babel/plugin-syntax-flow` via `babel/eslint-parser` (**this change**). I'd love to simplify this 😅. Switching to `hermes-eslint` for the RN monorepo codebase (D63541483) is unchanged. Changelog: [Internal] Reviewed By: robhogan, cipolleschi Differential Revision: D65272156 fbshipit-source-id: 3a2bbe3fcf8ed6057f6d994a0be4985e6bf46fa9
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Differential Revision: D65272155
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Reviewed By: vzaidman Differential Revision: D65272155
Summary: This is a mitigation for facebook#1549. Updates `babel-plugin-syntax-hermes-parser` to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Differential Revision: D65272155
Summary: Pull Request resolved: #1556 This is a mitigation for #1549. Updates `babel-plugin-syntax-hermes-parser` to include a new `parseLangTypes` option, which we will configure in React Native's Babel preset to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Reviewed By: pieterv Differential Revision: D65272155 fbshipit-source-id: b3be10410962ffffd4e0d483d10fe88d865c0783
Summary: Resolves facebook/hermes#1549. Changelog: [General][Fixed] - When using Babel with plain JavaScript files, support for additional user syntax plugins should be fixed (now uses Babel's parser instead of hermes-parser). There is no change for JS files annotated with `flow`, where extended JS syntax remains unsupported. Differential Revision: D65816797
Summary: Pull Request resolved: facebook#47568 Resolves facebook/hermes#1549. Changelog: [General][Fixed] - When using Babel with plain JavaScript files, support for additional user syntax plugins should be fixed (now uses Babel's parser instead of hermes-parser). There is no change for JS files annotated with `flow`, where extended JS syntax remains unsupported. Differential Revision: D65816797
Summary: Original Author: [email protected] Original Git: f2970e7 Original Reviewed By: pieterv Original Revision: D65272155 Pull Request resolved: #1556 This is a mitigation for #1549. Updates `babel-plugin-syntax-hermes-parser` to include a new `parseLangTypes` option, which we will configure in React Native's Babel preset to abort when the file contents do not include `flow`. **Context: React Native** Originally changed in facebook/react-native#46696, as our internal Flow support had diverged from `babel/plugin-syntax-flow` (facebook/react-native#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript/JSX in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses base `babel/parser` (**this change**). I'd love to simplify this 😅. Reviewed By: mattbfb Differential Revision: D65787624 fbshipit-source-id: b06f1499b2d02462777ac72f03d8bb5c713b0a19
As of 0.76.2, Babel syntax plugins including
// metro.config.js
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
hermesParser: false,
},
}; |
这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Shipped in React Native 0.76.2 (please update all |
…nfig (#47670) Summary: Now that we have `babel-plugin-syntax-hermes-parser` in `react-native/babel-preset` (since D63535216), it's no longer necessary to use `hermes-parser` directly in Metro in order to use newer Flow syntax. Babel with `babel-plugin-syntax-hermes-parser` is generally preferable, because it intelligently falls back to parsing with Babel for any non-`flow` files. See facebook/hermes#1549 for context. Changelog: [General][Fixed] metro-config: Don't use `hermes-parser` by default, prefer `babel-plugin-syntax-hermes-parser`, which supports other syntax plugins. Differential Revision: D66002056
…nfig (#47670) Summary: Pull Request resolved: #47670 Now that we have `babel-plugin-syntax-hermes-parser` in `react-native/babel-preset` (since D63535216), it's no longer necessary to use `hermes-parser` directly in Metro in order to use newer Flow syntax. Babel with `babel-plugin-syntax-hermes-parser` is generally preferable, because it intelligently falls back to parsing with Babel for any non-`flow` files. See facebook/hermes#1549 for context. Changelog: [General][Fixed] metro-config: Don't use `hermes-parser` by default, prefer `babel-plugin-syntax-hermes-parser`, which supports other syntax plugins. Reviewed By: huntie Differential Revision: D66002056 fbshipit-source-id: cf48acec347e2c0791872f8ca4b53f5f8af1c783
@robhogan I have a little problem here if I set the
Unfortunately changing all the affected files from
and this is my
Any suggestions on how to tackle this? BTW by just removing hermesParser I get this error:
and before you ask this is my libraries versions:
Should I consider rolling back to a previous version of React Native? If so, which version is the correct one to avoid this problem? Thanks in advance! |
Hi @MarlonAEC - that looks like a Metro bug probably unrelated to Hermes parser, but maybe you’re encountering it because your build is getting further. Can you reproduce it with code you can share? If so I’d be keen to take a closer look, this is a new one - a new issue over at https://github.com/facebook/metro would be the best place. |
Summary: Pull Request resolved: #47568 Resolves facebook/hermes#1549. Changelog: [General][Fixed] - When using Babel with plain JavaScript files, support for additional user syntax plugins should be fixed (now uses Babel's parser instead of hermes-parser). There is no change for JS files annotated with `flow`, where extended JS syntax remains unsupported. Reviewed By: blakef Differential Revision: D65816797 fbshipit-source-id: 9f05e86019548ac8727ee65c2e2c417d78a406d8
Side note for those landing here like I did : I also had to set |
Summary: Pull Request resolved: #47333 Motivated by facebook/hermes#1549. This was originally changed in #46696, as our internal Flow support had diverged from `babel/eslint-parser` (#46601). We effectively have three flavours of JavaScript in support: - Flow@latest for the `react-native` package, shipped as source — uses `hermes-parser`. - TypeScript for product code (community template, Expo) — uses `babel/plugin-syntax-typescript`. - Plain JavaScript or Flow in product code, *which may be extended with additional user Babel plugins and needs lenient parsing* — uses `babel/plugin-syntax-flow` via `babel/eslint-parser` (**this change**). I'd love to simplify this 😅. Switching to `hermes-eslint` for the RN monorepo codebase (D63541483) is unchanged. Changelog: [Internal] Reviewed By: robhogan, cipolleschi Differential Revision: D65272156 fbshipit-source-id: 3a2bbe3fcf8ed6057f6d994a0be4985e6bf46fa9
…nfig (#47670) Summary: Pull Request resolved: #47670 Now that we have `babel-plugin-syntax-hermes-parser` in `react-native/babel-preset` (since D63535216), it's no longer necessary to use `hermes-parser` directly in Metro in order to use newer Flow syntax. Babel with `babel-plugin-syntax-hermes-parser` is generally preferable, because it intelligently falls back to parsing with Babel for any non-`flow` files. See facebook/hermes#1549 for context. Changelog: [General][Fixed] metro-config: Don't use `hermes-parser` by default, prefer `babel-plugin-syntax-hermes-parser`, which supports other syntax plugins. Reviewed By: huntie Differential Revision: D66002056 fbshipit-source-id: cf48acec347e2c0791872f8ca4b53f5f8af1c783
Description
Since i upgraded from react-native 0.75.4 to 0.76 and the babel plugin "@babel/plugin-proposal-decorators" stopped working.
What we know:
I was not able to fix the issue by changing babel or @babel/plugin-proposal-decorators versions so probably is not something with babel setup.
I can confirm that brand new react-native 0.76.0 can not work with @babel/plugin-proposal-decorators as we can see on the reproducer.
The reproducer is a standard react-native 0.76.0 with "@babel/plugin-proposal-decorators": "^7.25.9" and a babel.config.js that i believe most of the users configure.
The reproducer can be found on:
https://github.com/lucaswitch/broken-babel-preset
I understand that it's not a problem of react-native project but is something that we can probably can be adjusted on the official babel preset.
Actually this plugin is used by a lot of developers including me and a lot of libraries need that configuration to be able to be used on a react-native project.
Steps to reproduce
I tested this issue only on IOS but i think it's not related to any platform since is a babel related problem.
I'm not a babel expert but i suspect there is something on @react-native/babel-preset that broke this configuration.
Created a little repro with a brand new bare react-native project and an small minimal decorator setup just to prove that is not transforming js syntax the right way on react-native.
React Native Version
0.76.0
Affected Platforms
Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/lucaswitch/broken-babel-preset
Screenshots and Videos
The text was updated successfully, but these errors were encountered: