UNPKG

1.14 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4// istanbul ignore next
5
6function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
7
8var _babylon = require("babylon");
9
10var babylon = _interopRequireWildcard(_babylon);
11
12/**
13 * Parse `code` with normalized options, collecting tokens and comments.
14 */
15
16exports["default"] = function (code) {
17 var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
18
19 var parseOpts = {
20 allowImportExportEverywhere: opts.looseModules,
21 allowReturnOutsideFunction: opts.looseModules,
22 allowHashBang: true,
23 ecmaVersion: 6,
24 strictMode: opts.strictMode,
25 sourceType: opts.sourceType,
26 locations: true,
27 features: opts.features || {},
28 plugins: opts.plugins || {}
29 };
30
31 if (opts.nonStandard) {
32 parseOpts.plugins.jsx = true;
33 parseOpts.plugins.flow = true;
34 }
35
36 return babylon.parse(code, parseOpts);
37};
38
39module.exports = exports["default"];
\No newline at end of file