1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | const babylon = require('@babel/parser');
|
12 |
|
13 |
|
14 |
|
15 | const options = {
|
16 | sourceType: 'module',
|
17 | allowHashBang: true,
|
18 | ecmaVersion: Infinity,
|
19 | allowImportExportEverywhere: true,
|
20 | allowReturnOutsideFunction: true,
|
21 | startLine: 1,
|
22 | tokens: true,
|
23 | plugins: [
|
24 | 'estree',
|
25 | 'jsx',
|
26 | 'asyncGenerators',
|
27 | 'classProperties',
|
28 | 'doExpressions',
|
29 | 'exportExtensions',
|
30 | 'functionBind',
|
31 | 'functionSent',
|
32 | 'objectRestSpread',
|
33 | 'dynamicImport',
|
34 | 'nullishCoalescingOperator',
|
35 | 'optionalChaining',
|
36 | ['decorators', {decoratorsBeforeExport: false}],
|
37 | ],
|
38 | };
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | module.exports = function() {
|
45 | return {
|
46 | parse(code) {
|
47 | return babylon.parse(code, options);
|
48 | },
|
49 | };
|
50 | };
|