@putout/engine-parser 11.2.0 → 11.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parse.js +14 -16
- package/lib/parsers/acorn.js +4 -3
- package/lib/print.js +3 -1
- package/package.json +5 -5
package/lib/parse.js
CHANGED
|
@@ -33,19 +33,17 @@ module.exports = (source, options) => {
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
}
|
|
36
|
+
const getParser = ({parser = 'babel', isTS, isFlow, isJSX, printer}) => ({
|
|
37
|
+
parse(source) {
|
|
38
|
+
const ast = toBabel(customParser(source, parser, {
|
|
39
|
+
isTS,
|
|
40
|
+
isFlow,
|
|
41
|
+
isJSX,
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
if (printer === 'recast')
|
|
45
|
+
moveOutDirectives(ast);
|
|
46
|
+
|
|
47
|
+
return ast;
|
|
48
|
+
},
|
|
49
|
+
});
|
package/lib/parsers/acorn.js
CHANGED
|
@@ -4,15 +4,15 @@ const once = require('once');
|
|
|
4
4
|
|
|
5
5
|
const initAcorn = once(() => {
|
|
6
6
|
const {Parser} = require('acorn');
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const stage3 = require('acorn-stage3');
|
|
9
|
+
const typescript = require('acorn-typescript').default;
|
|
9
10
|
|
|
10
|
-
return Parser.extend(
|
|
11
|
+
return Parser.extend(typescript(), stage3);
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
module.exports.parse = function acornParse(source) {
|
|
14
15
|
const parser = initAcorn();
|
|
15
|
-
|
|
16
16
|
const options = {
|
|
17
17
|
locations: true,
|
|
18
18
|
comment: true,
|
|
@@ -21,6 +21,7 @@ module.exports.parse = function acornParse(source) {
|
|
|
21
21
|
allowAwaitOutsideFunction: true,
|
|
22
22
|
allowReturnOutsideFunction: true,
|
|
23
23
|
allowImportExportEverywhere: true,
|
|
24
|
+
preserveParens: true,
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const tokensToAvoidEsprima = Array.from(parser.tokenizer(source, options));
|
package/lib/print.js
CHANGED
|
@@ -9,7 +9,9 @@ const {isArray} = Array;
|
|
|
9
9
|
|
|
10
10
|
const maybeArray = (a) => isArray(a) ? a : [a, {}];
|
|
11
11
|
|
|
12
|
-
const btoa = (a) => Buffer
|
|
12
|
+
const btoa = (a) => Buffer
|
|
13
|
+
.from(a, 'binary')
|
|
14
|
+
.toString('base64');
|
|
13
15
|
|
|
14
16
|
const addSourceMap = (sourceMapName, {code, map}) => !sourceMapName ? code : `${code}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(stringify(map))}\n`;
|
|
15
17
|
const fixStrictMode = (a) => a.replace(`\n\n\n'use strict'`, `\n\n'use strict'`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-parser",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.4.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout parser",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"report": "madrun report"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@putout/babel": "^
|
|
37
|
-
"@putout/printer": "^
|
|
36
|
+
"@putout/babel": "^3.0.0",
|
|
37
|
+
"@putout/printer": "^12.0.0",
|
|
38
38
|
"estree-to-babel": "^10.0.0",
|
|
39
39
|
"nano-memoize": "^3.0.11",
|
|
40
40
|
"once": "^1.4.0",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"acorn": "^8.1.1",
|
|
50
|
-
"acorn-jsx": "^5.0.2",
|
|
51
50
|
"acorn-stage3": "^4.0.0",
|
|
51
|
+
"acorn-typescript": "^1.4.13",
|
|
52
52
|
"c8": "^10.0.0",
|
|
53
53
|
"eslint": "^9.0.0",
|
|
54
54
|
"eslint-plugin-n": "^17.0.0",
|
|
55
55
|
"eslint-plugin-putout": "^23.0.0",
|
|
56
56
|
"espree": "^10.0.0",
|
|
57
57
|
"esprima": "^4.0.1",
|
|
58
|
-
"hermes-parser": "^0.
|
|
58
|
+
"hermes-parser": "^0.26.0",
|
|
59
59
|
"just-camel-case": "^6.2.0",
|
|
60
60
|
"lerna": "^6.0.1",
|
|
61
61
|
"madrun": "^10.0.0",
|