babel: Decorators are broken in 7
Bug Report
Current Behavior
Follow up to https://github.com/babel/babel/issues/7786 . No idea why that issue is closed, with a cliff-hanger. If you add {legacy: true}
option to the plugin, you’ll again get the error about the syntax not being enabled.
Input Code
@observer
class TextInput {}
Expected behavior/code It works
Babel Configuration (.babelrc, package.json, cli command)
{
plugins: [
...,
['@babel/plugin-proposal-decorators', {legacy: true}],
],
}
Environment
- Babel version(s): [v7.0.0-beta.46]
- Node/npm version: [e.g. Node 9.2.1/yarn 1.5.1]
- Monorepo [e.g. no]
- How you are using Babel: [
loader
]
Additional context/Screenshots So basically it goes like this:
First you get a warning Support for the experimental syntax 'decorators' isn't currently enabled
. You add '@babel/plugin-proposal-decorators'
to your plugins, you then get a warning about needing legacy
option, you add the legacy option and you’re back at Support for the experimental syntax 'decorators' isn't currently enabled
warning.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 22
- Comments: 16 (6 by maintainers)
Here is an example
babel.config.js
(you should delete .babelrc):Could you elaborate a bit more on this @abologna-r7 ?
I’m seeing this also.
Without a repo to reproduce the issue it might be difficult to triage the issue
So I figure it out by not using .babelrc at all, and instead using babel.config.js 😃
"plugins": [ ["@babel/plugin-proposal-decorators", { "legacy": true }], ["@babel/plugin-proposal-class-properties", { "loose" : true }], ],
Also getting the error mentioned above. Using @babel/core and plugins in the code block