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,
|
||||
decoratorsLegacy = false,
|
||||
decoratorsBeforeExport,
|
||||
pipelineProposal = "minimal",
|
||||
pipelineProposal,
|
||||
pipelineTopicToken,
|
||||
importAssertionsVersion = "september-2020",
|
||||
} = opts;
|
||||
|
||||
@ -21,6 +22,7 @@ export default (_: any, opts: any = {}) => {
|
||||
decoratorsLegacy,
|
||||
decoratorsBeforeExport,
|
||||
pipelineProposal,
|
||||
pipelineTopicToken,
|
||||
importAssertionsVersion,
|
||||
},
|
||||
],
|
||||
|
||||
@ -8,6 +8,7 @@ export default (_: any, opts: any = {}) => {
|
||||
decoratorsLegacy = false,
|
||||
decoratorsBeforeExport,
|
||||
pipelineProposal = "minimal",
|
||||
pipelineTopicToken = "%",
|
||||
recordAndTupleSyntax: recordAndTupleSyntax = "hash",
|
||||
} = opts;
|
||||
|
||||
@ -23,7 +24,10 @@ export default (_: any, opts: any = {}) => {
|
||||
[babelPlugins.syntaxRecordAndTuple, { syntaxType: recordAndTupleSyntax }],
|
||||
babelPlugins.syntaxModuleBlocks,
|
||||
babelPlugins.proposalExportDefaultFrom,
|
||||
[babelPlugins.proposalPipelineOperator, { proposal: pipelineProposal }],
|
||||
[
|
||||
babelPlugins.proposalPipelineOperator,
|
||||
{ proposal: pipelineProposal, topicToken: pipelineTopicToken },
|
||||
],
|
||||
babelPlugins.proposalDoExpressions,
|
||||
],
|
||||
};
|
||||
|
||||
@ -15,5 +15,45 @@ const require = createRequire(import.meta.url);
|
||||
}).code;
|
||||
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