@babel/traverse 7.4.0 → 7.5.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.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/lib/path/context.js +1 -1
- package/lib/path/index.js +2 -2
- package/lib/path/modification.js +2 -2
- package/lib/path/replacement.js +8 -0
- package/package.json +6 -6
package/lib/path/context.js
CHANGED
@@ -53,7 +53,7 @@ function _call(fns) {
|
|
53
53
|
const ret = fn.call(this.state, this, this.state);
|
54
54
|
|
55
55
|
if (ret && typeof ret === "object" && typeof ret.then === "function") {
|
56
|
-
throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support
|
56
|
+
throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
57
57
|
}
|
58
58
|
|
59
59
|
if (ret) {
|
package/lib/path/index.js
CHANGED
@@ -76,7 +76,7 @@ class NodePath {
|
|
76
76
|
this.parent = parent;
|
77
77
|
this.hub = hub;
|
78
78
|
this.contexts = [];
|
79
|
-
this.data =
|
79
|
+
this.data = Object.create(null);
|
80
80
|
this.shouldSkip = false;
|
81
81
|
this.shouldStop = false;
|
82
82
|
this.removed = false;
|
@@ -149,7 +149,7 @@ class NodePath {
|
|
149
149
|
|
150
150
|
getData(key, def) {
|
151
151
|
let val = this.data[key];
|
152
|
-
if (
|
152
|
+
if (val === undefined && def !== undefined) val = this.data[key] = def;
|
153
153
|
return val;
|
154
154
|
}
|
155
155
|
|
package/lib/path/modification.js
CHANGED
@@ -44,7 +44,7 @@ function insertBefore(nodes) {
|
|
44
44
|
|
45
45
|
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
|
46
46
|
return parentPath.insertBefore(nodes);
|
47
|
-
} else if (this.isNodeType("Expression") && this.
|
47
|
+
} else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
|
48
48
|
if (this.node) nodes.push(this.node);
|
49
49
|
return this.replaceExpressionWithStatements(nodes);
|
50
50
|
} else if (Array.isArray(this.container)) {
|
@@ -196,7 +196,7 @@ function unshiftContainer(listKey, nodes) {
|
|
196
196
|
key: 0
|
197
197
|
});
|
198
198
|
|
199
|
-
return path.
|
199
|
+
return path._containerInsertBefore(nodes);
|
200
200
|
}
|
201
201
|
|
202
202
|
function pushContainer(listKey, nodes) {
|
package/lib/path/replacement.js
CHANGED
@@ -206,6 +206,8 @@ function replaceExpressionWithStatements(nodes) {
|
|
206
206
|
return this.replaceWith(toSequenceExpression)[0].get("expressions");
|
207
207
|
}
|
208
208
|
|
209
|
+
const functionParent = this.getFunctionParent();
|
210
|
+
const isParentAsync = functionParent && functionParent.is("async");
|
209
211
|
const container = t().arrowFunctionExpression([], t().blockStatement(nodes));
|
210
212
|
this.replaceWith(t().callExpression(container, []));
|
211
213
|
this.traverse(hoistVariablesVisitor);
|
@@ -235,6 +237,12 @@ function replaceExpressionWithStatements(nodes) {
|
|
235
237
|
|
236
238
|
const callee = this.get("callee");
|
237
239
|
callee.arrowFunctionToExpression();
|
240
|
+
|
241
|
+
if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t().FUNCTION_TYPES)) {
|
242
|
+
callee.set("async", true);
|
243
|
+
this.replaceWith(t().awaitExpression(this.node));
|
244
|
+
}
|
245
|
+
|
238
246
|
return callee.get("body.body");
|
239
247
|
}
|
240
248
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.5.0",
|
4
4
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
5
5
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
6
6
|
"homepage": "https://babeljs.io/",
|
@@ -12,11 +12,11 @@
|
|
12
12
|
"main": "lib/index.js",
|
13
13
|
"dependencies": {
|
14
14
|
"@babel/code-frame": "^7.0.0",
|
15
|
-
"@babel/generator": "^7.
|
15
|
+
"@babel/generator": "^7.5.0",
|
16
16
|
"@babel/helper-function-name": "^7.1.0",
|
17
|
-
"@babel/helper-split-export-declaration": "^7.4.
|
18
|
-
"@babel/parser": "^7.
|
19
|
-
"@babel/types": "^7.
|
17
|
+
"@babel/helper-split-export-declaration": "^7.4.4",
|
18
|
+
"@babel/parser": "^7.5.0",
|
19
|
+
"@babel/types": "^7.5.0",
|
20
20
|
"debug": "^4.1.0",
|
21
21
|
"globals": "^11.1.0",
|
22
22
|
"lodash": "^4.17.11"
|
@@ -24,5 +24,5 @@
|
|
24
24
|
"devDependencies": {
|
25
25
|
"@babel/helper-plugin-test-runner": "^7.0.0"
|
26
26
|
},
|
27
|
-
"gitHead": "
|
27
|
+
"gitHead": "49da9a07c81156e997e60146eb001ea77b7044c4"
|
28
28
|
}
|