Thiago Arrais a4170b5e32 Transform for F# Pipeline (#9984)
* Transform for F#-style await

Inludes support for optimizing single-parameter arrow functions

* Wait until optimization before pushing placeholder into scope
2019-06-30 12:53:22 +02:00

25 lines
704 B
JavaScript

import { declare } from "@babel/helper-plugin-utils";
export const proposals = ["minimal", "smart", "fsharp"];
export default declare((api, { proposal }) => {
api.assertVersion(7);
if (typeof proposal !== "string" || !proposals.includes(proposal)) {
throw new Error(
"The pipeline operator plugin requires a 'proposal' option." +
"'proposal' must be one of: " +
proposals.join(", ") +
". More details: https://babeljs.io/docs/en/next/babel-plugin-proposal-pipeline-operator",
);
}
return {
name: "syntax-pipeline-operator",
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push(["pipelineOperator", { proposal }]);
},
};
});