Update syntax-decorators options (#7938)
* Add decoratorsBeforeExport to the syntax plugin * Require legacy: true, like in the transform plugin
This commit is contained in:
@@ -8,9 +8,35 @@ export default declare((api, options) => {
|
||||
throw new Error("'legacy' must be a boolean.");
|
||||
}
|
||||
|
||||
if (legacy !== true) {
|
||||
throw new Error(
|
||||
"The new decorators proposal is not supported yet." +
|
||||
' You must pass the `"legacy": true` option to' +
|
||||
" @babel/plugin-syntax-decorators",
|
||||
);
|
||||
}
|
||||
|
||||
let { decoratorsBeforeExport } = options;
|
||||
if (decoratorsBeforeExport !== undefined) {
|
||||
if (legacy) {
|
||||
throw new Error(
|
||||
"'decoratorsBeforeExport' can't be used with legacy decorators.",
|
||||
);
|
||||
}
|
||||
if (typeof decoratorsBeforeExport !== "boolean") {
|
||||
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
||||
}
|
||||
} else if (!legacy) {
|
||||
decoratorsBeforeExport = true;
|
||||
}
|
||||
|
||||
return {
|
||||
manipulateOptions(opts, parserOpts) {
|
||||
parserOpts.plugins.push(legacy ? "decorators-legacy" : "decorators");
|
||||
parserOpts.plugins.push(
|
||||
legacy
|
||||
? "decorators-legacy"
|
||||
: ["decorators", { decoratorsBeforeExport }],
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user