add decoratorsVersion support to babel-standalone

This commit is contained in:
Huáng Jùnliàng 2022-01-14 15:43:51 -05:00 committed by Nicolò Ribaudo
parent 9ecadfd8d2
commit 62acebe844
4 changed files with 26 additions and 3 deletions

View File

@ -5,7 +5,8 @@ export default (_: any, opts: any = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
decoratorsLegacy,
decoratorsVersion,
decoratorsBeforeExport,
pipelineProposal,
pipelineTopicToken,
@ -20,6 +21,7 @@ export default (_: any, opts: any = {}) => {
loose,
useBuiltIns,
decoratorsLegacy,
decoratorsVersion,
decoratorsBeforeExport,
pipelineProposal,
pipelineTopicToken,

View File

@ -5,7 +5,8 @@ export default (_: any, opts: any = {}) => {
const {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
decoratorsLegacy,
decoratorsVersion,
decoratorsBeforeExport,
pipelineProposal,
pipelineTopicToken,
@ -20,6 +21,7 @@ export default (_: any, opts: any = {}) => {
loose,
useBuiltIns,
decoratorsLegacy,
decoratorsVersion,
decoratorsBeforeExport,
pipelineProposal,
pipelineTopicToken,

View File

@ -6,6 +6,7 @@ export default (_: any, opts: any = {}) => {
loose = false,
useBuiltIns = false,
decoratorsLegacy = false,
decoratorsVersion = "2018-09",
decoratorsBeforeExport,
pipelineProposal = "minimal",
pipelineTopicToken = "%",
@ -17,7 +18,10 @@ export default (_: any, opts: any = {}) => {
plugins: [
[
babelPlugins.proposalDecorators,
{ legacy: decoratorsLegacy, decoratorsBeforeExport },
{
version: decoratorsLegacy ? "legacy" : decoratorsVersion,
decoratorsBeforeExport,
},
],
[
babelPlugins.proposalPipelineOperator,

View File

@ -55,5 +55,20 @@ _ref = x, _ref;"
_ref = x, _ref;"
`);
});
it("should support decorators versioned 2021-12", () => {
const output = Babel.transform("@dec class C {}", {
plugins: [["external-helpers", { helperVersion: "7.100.0" }]],
presets: [
[
"stage-1",
{
decoratorsVersion: "2021-12",
decoratorsBeforeExport: false,
},
],
],
}).code;
expect(output).toMatch("babelHelpers.applyDecs");
});
},
);