_babylon_options.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const getOption = require("../lib/util.js").getOption;
  2. module.exports = function (options) {
  3. // The goal here is to tolerate as much syntax as possible, since Recast
  4. // is not in the business of forbidding anything. If you want your
  5. // parser to be more restrictive for some reason, you can always pass
  6. // your own parser object to recast.parse.
  7. return {
  8. sourceType: getOption(options, "sourceType", "module"),
  9. strictMode: getOption(options, "strictMode", false),
  10. allowImportExportEverywhere: true,
  11. allowReturnOutsideFunction: true,
  12. startLine: 1,
  13. tokens: getOption(options, "tokens", true),
  14. plugins: [
  15. "asyncGenerators",
  16. "bigInt",
  17. "classPrivateMethods",
  18. "classPrivateProperties",
  19. "classProperties",
  20. "decorators-legacy",
  21. "doExpressions",
  22. "dynamicImport",
  23. "exportDefaultFrom",
  24. "exportExtensions",
  25. "exportNamespaceFrom",
  26. "functionBind",
  27. "functionSent",
  28. "importMeta",
  29. "nullishCoalescingOperator",
  30. "numericSeparator",
  31. "objectRestSpread",
  32. "optionalCatchBinding",
  33. "optionalChaining",
  34. "pipelineOperator",
  35. "throwExpressions",
  36. ]
  37. };
  38. };