@putout/engine-parser 5.0.0 β 5.2.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/README.md +5 -5
- package/lib/parsers/babel/index.js +5 -6
- package/lib/parsers/babel/plugins.js +2 -4
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/engine-parser.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/engine-parser"npm"
|
|
5
5
|
|
|
6
|
-
π[
|
|
6
|
+
π[**Putout**](https://github.com/coderaiser/putout) engine that parses input.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -19,7 +19,7 @@ npm i @putout/engine-parser
|
|
|
19
19
|
- [esprima](https://esprima.org/)
|
|
20
20
|
- [tenko](https://github.com/pvdz/tenko)
|
|
21
21
|
|
|
22
|
-
Any parser should be installed before use, but you can be
|
|
22
|
+
Any parser should be installed before use, but you can be sure that `@babel/parse` always installed.
|
|
23
23
|
|
|
24
24
|
## API
|
|
25
25
|
|
|
@@ -50,7 +50,7 @@ You have two ways to benefit from source map generation:
|
|
|
50
50
|
- using `Recast` print;
|
|
51
51
|
- using `Babel` generator;
|
|
52
52
|
|
|
53
|
-
#### Generate sourcemaps
|
|
53
|
+
#### Generate sourcemaps using Recast
|
|
54
54
|
|
|
55
55
|
```js
|
|
56
56
|
const source = `const hello = 'world';`;
|
|
@@ -63,9 +63,9 @@ print(ast, {sourceMapName: 'hello.map'});
|
|
|
63
63
|
{"version":3,"sources":["hello.js"],"names":[],"mappings":"AAAA...","file":"hello.map","sourcesContent":["const hello = 'world';"]}`;
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
#### Generate sourcemaps
|
|
66
|
+
#### Generate sourcemaps using Babel
|
|
67
67
|
|
|
68
|
-
To generate sourcemap
|
|
68
|
+
To generate sourcemap using babel generator, you should use babel parser before.
|
|
69
69
|
This is low level transformation, because `Babel` doesn't preserve any formatting.
|
|
70
70
|
|
|
71
71
|
```js
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {assign} = Object;
|
|
4
|
-
|
|
5
3
|
const once = require('once');
|
|
6
4
|
|
|
7
5
|
// stricter validation to prevent even more invalid ASTs: not only
|
|
@@ -11,15 +9,16 @@ const once = require('once');
|
|
|
11
9
|
// not a valid identifier.
|
|
12
10
|
process.env.BABEL_TYPES_8_BREAKING = true;
|
|
13
11
|
|
|
14
|
-
const initBabel = once(() => require('@babel/parser'));
|
|
15
|
-
const clean = (a) => a.filter(Boolean);
|
|
16
|
-
const getFlow = (a) => a.includes('// @flow');
|
|
17
|
-
|
|
18
12
|
const plugins = require('./plugins');
|
|
19
13
|
const options = require('./options');
|
|
20
14
|
|
|
21
15
|
const moveOutDirectives = require('./move-out-directives');
|
|
22
16
|
|
|
17
|
+
const getFlow = (a) => a.includes('// @flow');
|
|
18
|
+
const clean = (a) => a.filter(Boolean);
|
|
19
|
+
const initBabel = once(() => require('@babel/parser'));
|
|
20
|
+
const {assign} = Object;
|
|
21
|
+
|
|
23
22
|
// There is a difference in options naming for babel and recast
|
|
24
23
|
// recast -> sourceFileName
|
|
25
24
|
// babel, putout: sourceFilename
|
|
@@ -9,12 +9,10 @@ module.exports = [
|
|
|
9
9
|
'classPrivateMethods',
|
|
10
10
|
'classProperties',
|
|
11
11
|
'decorators-legacy',
|
|
12
|
+
'destructuringPrivate',
|
|
12
13
|
'numericSeparator',
|
|
13
14
|
'exportDefaultFrom',
|
|
14
15
|
'throwExpressions',
|
|
15
|
-
|
|
16
|
-
recordAndTupleSyntaxType: 'hash',
|
|
17
|
-
syntaxType: 'hash',
|
|
18
|
-
}],
|
|
16
|
+
'recordAndTuple',
|
|
19
17
|
];
|
|
20
18
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-parser",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "πPutout parser",
|
|
7
7
|
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/engine-parser#readme",
|
|
8
8
|
"main": "./lib/parser.js",
|
|
9
|
+
"commitType": "colon",
|
|
9
10
|
"release": false,
|
|
10
11
|
"tag": false,
|
|
11
12
|
"changelog": false,
|
|
@@ -33,10 +34,10 @@
|
|
|
33
34
|
"report": "madrun report"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@babel/generator": "^7.
|
|
37
|
-
"@babel/parser": "^7.
|
|
38
|
-
"@babel/template": "^7.10
|
|
39
|
-
"@babel/types": "^7.
|
|
37
|
+
"@babel/generator": "^7.19.0",
|
|
38
|
+
"@babel/parser": "^7.19.0",
|
|
39
|
+
"@babel/template": "^7.18.10",
|
|
40
|
+
"@babel/types": "^7.19.0",
|
|
40
41
|
"@putout/recast": "^1.1.0",
|
|
41
42
|
"estree-to-babel": "^5.0.0",
|
|
42
43
|
"nano-memoize": "^1.1.8",
|
|
@@ -48,19 +49,18 @@
|
|
|
48
49
|
"putout-engine"
|
|
49
50
|
],
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@cloudcmd/stub": "^3.0.0",
|
|
52
52
|
"acorn": "^8.1.1",
|
|
53
53
|
"acorn-jsx": "^5.0.2",
|
|
54
54
|
"acorn-stage3": "^4.0.0",
|
|
55
55
|
"c8": "^7.5.0",
|
|
56
56
|
"eslint": "^8.0.1",
|
|
57
|
-
"eslint-plugin-
|
|
58
|
-
"eslint-plugin-putout": "^
|
|
57
|
+
"eslint-plugin-n": "^15.2.4",
|
|
58
|
+
"eslint-plugin-putout": "^16.0.0",
|
|
59
59
|
"espree": "^9.0.0",
|
|
60
60
|
"esprima": "^4.0.1",
|
|
61
|
-
"hermes-parser": "^0.
|
|
61
|
+
"hermes-parser": "^0.9.0",
|
|
62
62
|
"just-camel-case": "^4.0.2",
|
|
63
|
-
"lerna": "^
|
|
63
|
+
"lerna": "^5.0.0",
|
|
64
64
|
"madrun": "^9.0.0",
|
|
65
65
|
"montag": "^1.0.0",
|
|
66
66
|
"nodemon": "^2.0.1",
|