hermes-parser 0.33.1 → 0.33.2
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 +1 -0
- package/dist/HermesToESTreeAdapter.js +1 -0
- package/dist/HermesToESTreeAdapter.js.flow +1 -0
- package/dist/ParserOptions.js.flow +2 -1
- package/dist/index.js +7 -1
- package/dist/index.js.flow +4 -2
- package/dist/src/HermesToESTreeAdapter.js +1 -0
- package/dist/src/index.js +7 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,4 +11,5 @@ The Hermes parser exposes a single `parse(code, [options])` function, where `cod
|
|
|
11
11
|
- **tokens**: `boolean`, defaults to `false`. If `true`, add all tokens to a `tokens` property on the root node.
|
|
12
12
|
- **transformOptions**: `object`. Options to be supplied to relevant transforms.
|
|
13
13
|
- `TransformEnumSyntax`
|
|
14
|
+
- `enable`: `boolean` - Whether to enable the transform. By default, `false`.
|
|
14
15
|
- `getRuntime` (optional): `() => Expression` - The expression which should be a reference to the Flow Enums runtime. By default, is `require('flow-enums-runtime')`.
|
package/dist/index.js
CHANGED
|
@@ -139,6 +139,8 @@ function getOptions(options = { ...DEFAULTS
|
|
|
139
139
|
|
|
140
140
|
// eslint-disable-next-line no-redeclare
|
|
141
141
|
function parse(code, opts) {
|
|
142
|
+
var _options$transformOpt, _options$transformOpt2;
|
|
143
|
+
|
|
142
144
|
const options = getOptions(opts);
|
|
143
145
|
const ast = HermesParser.parse(code, options);
|
|
144
146
|
const estreeAdapter = new _HermesToESTreeAdapter.default(options, code);
|
|
@@ -148,7 +150,11 @@ function parse(code, opts) {
|
|
|
148
150
|
return estreeAST;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) =>
|
|
153
|
+
const loweredESTreeAST = [(_options$transformOpt = options.transformOptions) != null && (_options$transformOpt2 = _options$transformOpt.TransformEnumSyntax) != null && _options$transformOpt2.enable ? TransformEnumSyntax.transformProgram : null, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => {
|
|
154
|
+
var _transform;
|
|
155
|
+
|
|
156
|
+
return (_transform = transform == null ? void 0 : transform(ast, options)) != null ? _transform : ast;
|
|
157
|
+
}, estreeAST);
|
|
152
158
|
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);
|
|
153
159
|
}
|
|
154
160
|
|
package/dist/index.js.flow
CHANGED
|
@@ -98,12 +98,14 @@ export function parse(
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const loweredESTreeAST = [
|
|
101
|
-
TransformEnumSyntax
|
|
101
|
+
options.transformOptions?.TransformEnumSyntax?.enable
|
|
102
|
+
? TransformEnumSyntax.transformProgram
|
|
103
|
+
: null,
|
|
102
104
|
TransformMatchSyntax.transformProgram,
|
|
103
105
|
TransformComponentSyntax.transformProgram,
|
|
104
106
|
TransformRecordSyntax.transformProgram,
|
|
105
107
|
StripFlowTypesForBabel.transformProgram,
|
|
106
|
-
].reduce((ast, transform) => transform(ast, options), estreeAST);
|
|
108
|
+
].reduce((ast, transform) => transform?.(ast, options) ?? ast, estreeAST);
|
|
107
109
|
|
|
108
110
|
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);
|
|
109
111
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -139,6 +139,8 @@ function getOptions(options = { ...DEFAULTS
|
|
|
139
139
|
|
|
140
140
|
// eslint-disable-next-line no-redeclare
|
|
141
141
|
function parse(code, opts) {
|
|
142
|
+
var _options$transformOpt, _options$transformOpt2;
|
|
143
|
+
|
|
142
144
|
const options = getOptions(opts);
|
|
143
145
|
const ast = HermesParser.parse(code, options);
|
|
144
146
|
const estreeAdapter = new _HermesToESTreeAdapter.default(options, code);
|
|
@@ -148,7 +150,11 @@ function parse(code, opts) {
|
|
|
148
150
|
return estreeAST;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
const loweredESTreeAST = [TransformEnumSyntax.transformProgram, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) =>
|
|
153
|
+
const loweredESTreeAST = [(_options$transformOpt = options.transformOptions) != null && (_options$transformOpt2 = _options$transformOpt.TransformEnumSyntax) != null && _options$transformOpt2.enable ? TransformEnumSyntax.transformProgram : null, TransformMatchSyntax.transformProgram, TransformComponentSyntax.transformProgram, TransformRecordSyntax.transformProgram, StripFlowTypesForBabel.transformProgram].reduce((ast, transform) => {
|
|
154
|
+
var _transform;
|
|
155
|
+
|
|
156
|
+
return (_transform = transform == null ? void 0 : transform(ast, options)) != null ? _transform : ast;
|
|
157
|
+
}, estreeAST);
|
|
152
158
|
return TransformESTreeToBabel.transformProgram(loweredESTreeAST, options);
|
|
153
159
|
}
|
|
154
160
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-parser",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "A JavaScript parser built from the Hermes engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git@github.com:facebook/hermes.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"hermes-estree": "0.33.
|
|
12
|
+
"hermes-estree": "0.33.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/parser": "7.7.4",
|