Current Behavior
when i use Babel.transform(version: @babel/[email protected]) set presets stage-0, i got an error
Error: [BABEL] unknown: The decorators plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you want to use the legacy decorators semantics, you can set the 'legacy: true' option. (While processing: "base$1$0$0$0")
But I use the old version(@babel/[email protected]) and the same behavior works
Input Code
import * as Babel from "@babel/standalone";
const testCode = `
class App extends React.Component {
state = { value: '' }
onChange = e => {
this.setState({value: e.target.value});
}
render() {
return (
<label>
Enter a value111111:
<br />
<input type="text" value={this.state.value} onChange={this.onChange} />
</label>
)
}
}
`;
const outputCode = Babel.transform(testCode, {
presets: ["react", "stage-0"],
plugins: [
"proposal-class-properties",
["proposal-decorators", { legacy: true }]
]
}).code;
Expected behavior/code
A clear and concise description of what you expected to happen (or code).
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
babel.config.jsEnvironment
@babel/standalone version: v7.8.6
Node/npm version: v10.16.0/v6.9.0
OS: macOS v10.15.1
Possible Solution
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.


Hey @songyule! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
We should add default value true for decoratorsBeforeExport options accepted in the following places:
and preset-stage-1.js, preset-stage-2.js.
PR is welcome!
See Nicol貌's comment below.
We didn't add a default value on purpose: it wasn't clear which one we should have used. The current proposal has decorators _after_ export, but it's a completely different proposal from the one implemented in Babel.
This is a configuration error: in that sandbox, both "modern" and "legacy" decorators are enabled. "modern" decorators using the stage-0 preset, and "legacy" using the plugin.
This should work:
const outputCode = Babel.transform(testCode, {
presets: [
"react",
["stage-0", { decoratorsLegacy: true }]
]
}).code;
We didn't add a default value on purpose: it wasn't clear which one we should have used. The current proposal has decorators _after_ export, but it's a completely different proposal from the one implemented in Babel.
This is a configuration error: in that sandbox, both "modern" and "legacy" decorators are enabled. "modern" decorators using the
stage-0preset, and "legacy" using the plugin.This should work:
const outputCode = Babel.transform(testCode, { presets: [ "react", ["stage-0", { decoratorsLegacy: true }] ] }).code;
thx, It's ready to work
Most helpful comment
We didn't add a default value on purpose: it wasn't clear which one we should have used. The current proposal has decorators _after_ export, but it's a completely different proposal from the one implemented in Babel.
This is a configuration error: in that sandbox, both "modern" and "legacy" decorators are enabled. "modern" decorators using the
stage-0preset, and "legacy" using the plugin.This should work: