index.js 1.4 KB

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