UNPKG

1.36 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = traverse;
5
6var _path = _interopRequireDefault(require("path"));
7
8var _core = require("@babel/core");
9
10var _plugin = _interopRequireDefault(require("./plugin"));
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14function traverse(source, filename, opts) {
15 const extname = _path.default.extname(filename);
16
17 return (0, _core.transformSync)(source, {
18 filename,
19 babelrc: false,
20 configFile: false,
21 code: false,
22 ast: false,
23 plugins: [[_plugin.default, opts]],
24 sourceType: 'unambiguous',
25 parserOpts: {
26 allowImportExportEverywhere: true,
27 allowReturnOutsideFunction: true,
28 allowSuperOutsideMethod: true,
29 sourceType: 'unambiguous',
30 sourceFilename: filename,
31 plugins: ['jsx', extname === '.ts' || extname === '.tsx' ? 'typescript' : 'flow', 'doExpressions', 'objectRestSpread', 'decorators-legacy', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'exportDefaultFrom', 'exportNamespaceFrom', 'asyncGenerators', 'functionBind', 'functionSent', 'dynamicImport', 'numericSeparator', 'optionalChaining', 'importMeta', 'bigInt', 'optionalCatchBinding', 'throwExpressions', ['pipelineOperator', {
32 proposal: 'minimal'
33 }], 'nullishCoalescingOperator']
34 }
35 });
36}
\No newline at end of file