feat: support hack pipeline in @babel/standalone (#13555)
This commit is contained in:
parent
ff287ac5a5
commit
15f2f171ab
@ -7,7 +7,8 @@ export default (_: any, opts: any = {}) => {
|
|||||||
useBuiltIns = false,
|
useBuiltIns = false,
|
||||||
decoratorsLegacy = false,
|
decoratorsLegacy = false,
|
||||||
decoratorsBeforeExport,
|
decoratorsBeforeExport,
|
||||||
pipelineProposal = "minimal",
|
pipelineProposal,
|
||||||
|
pipelineTopicToken,
|
||||||
importAssertionsVersion = "september-2020",
|
importAssertionsVersion = "september-2020",
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ export default (_: any, opts: any = {}) => {
|
|||||||
decoratorsLegacy,
|
decoratorsLegacy,
|
||||||
decoratorsBeforeExport,
|
decoratorsBeforeExport,
|
||||||
pipelineProposal,
|
pipelineProposal,
|
||||||
|
pipelineTopicToken,
|
||||||
importAssertionsVersion,
|
importAssertionsVersion,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -8,6 +8,7 @@ export default (_: any, opts: any = {}) => {
|
|||||||
decoratorsLegacy = false,
|
decoratorsLegacy = false,
|
||||||
decoratorsBeforeExport,
|
decoratorsBeforeExport,
|
||||||
pipelineProposal = "minimal",
|
pipelineProposal = "minimal",
|
||||||
|
pipelineTopicToken = "%",
|
||||||
recordAndTupleSyntax: recordAndTupleSyntax = "hash",
|
recordAndTupleSyntax: recordAndTupleSyntax = "hash",
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
@ -23,7 +24,10 @@ export default (_: any, opts: any = {}) => {
|
|||||||
[babelPlugins.syntaxRecordAndTuple, { syntaxType: recordAndTupleSyntax }],
|
[babelPlugins.syntaxRecordAndTuple, { syntaxType: recordAndTupleSyntax }],
|
||||||
babelPlugins.syntaxModuleBlocks,
|
babelPlugins.syntaxModuleBlocks,
|
||||||
babelPlugins.proposalExportDefaultFrom,
|
babelPlugins.proposalExportDefaultFrom,
|
||||||
[babelPlugins.proposalPipelineOperator, { proposal: pipelineProposal }],
|
[
|
||||||
|
babelPlugins.proposalPipelineOperator,
|
||||||
|
{ proposal: pipelineProposal, topicToken: pipelineTopicToken },
|
||||||
|
],
|
||||||
babelPlugins.proposalDoExpressions,
|
babelPlugins.proposalDoExpressions,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,5 +15,45 @@ const require = createRequire(import.meta.url);
|
|||||||
}).code;
|
}).code;
|
||||||
expect(output).toBe("0.3m;");
|
expect(output).toBe("0.3m;");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should support hack pipeline", () => {
|
||||||
|
const output = Babel.transform("x |> %", {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
"stage-1",
|
||||||
|
{
|
||||||
|
pipelineProposal: "hack",
|
||||||
|
decoratorsBeforeExport: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
}).code;
|
||||||
|
expect(output).toMatchInlineSnapshot(`
|
||||||
|
"var _ref;
|
||||||
|
|
||||||
|
_ref = x, _ref;"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should support hack pipeline with `#` topic token", () => {
|
||||||
|
const output = Babel.transform("x |> #", {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
"stage-1",
|
||||||
|
{
|
||||||
|
pipelineProposal: "hack",
|
||||||
|
pipelineTopicToken: "#",
|
||||||
|
recordAndTupleSyntax: "bar",
|
||||||
|
decoratorsBeforeExport: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
}).code;
|
||||||
|
expect(output).toMatchInlineSnapshot(`
|
||||||
|
"var _ref;
|
||||||
|
|
||||||
|
_ref = x, _ref;"
|
||||||
|
`);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user