Parser `decorators` plugin option `decoratorsBeforeExport` no longer defaulting
See original GitHub issueBug Report
Current Behavior
In a recent v7 release (maybe even the final?), the parser decorators
plugin option decoratorsBeforeExport
no longer defaults as it used to.
const { parse } = require('@babel/core')
const result = parse(code, {
parserOpts: {
plugins: [
'decorators'
]
}
})
Results in an error:
/Users/jaydenseric/Sites/demo/node_modules/@babel/core/lib/transformation/normalize-file.js:209
throw err;
^
Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean.
This is unexpected, as the decoratorsBeforeExport
option is meant to default to false
. Manually providing the same value as the supposed default works:
const result = parse(code, {
parserOpts: {
plugins: [
- 'decorators'
+ ['decorators', { decoratorsBeforeExport: false }]
]
}
})
Expected behavior/code A clear and concise description of what you expected to happen (or code).
Babel Configuration (.babelrc, package.json, cli command)
N/A.
Environment
- Babel version(s): v7.0.0
- Node/npm version: Node.js v10.9.0, npm v6.4.0
- OS: macOS
- Monorepo [e.g. yes/no/Lerna]: No
- How you are using Babel: [e.g.
cli
,register
,loader
]: API
Possible Solution
Additional context/Screenshots
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:29 (12 by maintainers)
Top Results From Across the Web
The decorators Plugin when .version is '2018-09' or not ...
The decorators Plugin when .version is '2018-09' or not specified, requires a 'decoratorsBeforeExport' option, whose value must be a boolean.
Read more >babel/plugin-proposal-decorators
⚠️ If you specify the decoratorsBeforeExport option, version defaults to "2018-09" . decoratorsBeforeExport. This option: is disallowed when using version: " ...
Read more >@babel/plugin-syntax-export-default-from - Package Manager
Fast, reliable, and secure dependency management.
Read more >this experimental syntax requires enabling one of ... - You.com
ESLint Plugin Settings for VSCode (autofix on save, Jest aware, babel parser ... caused by using decorators before export default ... , which...
Read more >@babel/core - NPM Package Versions - Socket
babel-helpers , babel-plugin-transform-destructuring ... #14695 [parser] Make decoratorsBeforeExport default to false (@nicolo-ribaudo).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m struggling with this right now, when I set this:
OR
For both I get the same error
'decoratorsBeforeExport' can't be used with legacy decorators.
if I remove the
legacy
flag, like this:I get “The new decorators proposal is not supported yet. You must pass the
"legacy": true
option to @babel/plugin-proposal-decorators”.if I remove the
decoratorsBeforeExport
entirely and just do the legacy flag,I am able to proceed…
However this does now cause errors with using decorators and then using export default. I’m aware the spec is ‘still in flux’ but what is the way to configure this where I can use decorators like
Is this no longer able to be done?
recently was getting problem with this error and installed npm install --save-dev @babel/plugin-proposal-decorators and setup
"babel": { "plugins": [ [ "@babel/plugin-proposal-decorators", { "legacy": true } ] ], "presets": [ "react-app" ] },
this run my code with some errors, but app was working, I’m a beginner, so hope this comment is relevant