Blame view

node_modules/recast/parsers/babel.js 667 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  "use strict";
  
  // Prefer the new @babel/parser package, but fall back to babylon if
  // that's what's available.
  const parser = exports.parser = function () {
    try {
      return require("@babel/parser");
    } catch (e) {
      return require("babylon");
    }
  }();
  
  // This module is suitable for passing as options.parser when calling
  // recast.parse to process JavaScript code with Babel:
  //
  //   const ast = recast.parse(source, {
  //     parser: require("recast/parsers/babel")
  //   });
  //
  exports.parse = function (source, options) {
    options = require("./_babel_options.js")(options);
    options.plugins.push("jsx", "flow");
    return parser.parse(source, options);
  };