1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
8 | const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
|
9 | const TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
|
10 | const documentationURL = "https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator";
|
11 | var _default = exports.default = (0, _helperPluginUtils.declare)((api, {
|
12 | proposal,
|
13 | topicToken
|
14 | }) => {
|
15 | api.assertVersion(7);
|
16 | if (typeof proposal !== "string" || !PIPELINE_PROPOSALS.includes(proposal)) {
|
17 | const proposalList = PIPELINE_PROPOSALS.map(p => `"${p}"`).join(", ");
|
18 | throw new Error(`The pipeline plugin requires a "proposal" option. "proposal" must be one of: ${proposalList}. See <${documentationURL}>.`);
|
19 | }
|
20 | if (proposal === "hack" && !TOPIC_TOKENS.includes(topicToken)) {
|
21 | const topicTokenList = TOPIC_TOKENS.map(t => `"${t}"`).join(", ");
|
22 | throw new Error(`The pipeline plugin in "proposal": "hack" mode also requires a "topicToken" option. "topicToken" must be one of: ${topicTokenList}. See <${documentationURL}>.`);
|
23 | }
|
24 | return {
|
25 | name: "syntax-pipeline-operator",
|
26 | manipulateOptions(opts, parserOpts) {
|
27 | parserOpts.plugins.push(["pipelineOperator", {
|
28 | proposal,
|
29 | topicToken
|
30 | }]);
|
31 | opts.generatorOpts.topicToken = topicToken;
|
32 | }
|
33 | };
|
34 | });
|
35 |
|
36 |
|