| 1 | import { declare } from "@babel/helper-plugin-utils"; |
| 2 | import syntaxPipelineOperator from "@babel/plugin-syntax-pipeline-operator"; |
| 3 | import minimalVisitor from "./minimalVisitor"; |
| 4 | import hackVisitor from "./hackVisitor"; |
| 5 | import fsharpVisitor from "./fsharpVisitor"; |
| 6 | import smartVisitor from "./smartVisitor"; |
| 7 | import type { Options } from "@babel/plugin-syntax-pipeline-operator"; |
| 8 | |
| 9 | const visitorsPerProposal = { |
| 10 | minimal: minimalVisitor, |
| 11 | hack: hackVisitor, |
| 12 | fsharp: fsharpVisitor, |
| 13 | smart: smartVisitor, |
| 14 | }; |
| 15 | |
| 16 | export default declare((api, options: Options) => { |
| 17 | api.assertVersion(7); |
| 18 | |
| 19 | const { proposal } = options; |
| 20 | |
| 21 | if (proposal === "smart") { |
| 22 | console.warn( |
| 23 | `The smart-mix pipe operator is deprecated. Use "proposal": "hack" instead.`, |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | return { |
| 28 | name: "proposal-pipeline-operator", |
| 29 | inherits: syntaxPipelineOperator, |
| 30 | visitor: visitorsPerProposal[options.proposal], |
| 31 | }; |
| 32 | }); |