@babel/traverse 7.14.7 → 7.14.8
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/conversion.js +22 -1
- package/lib/scope/index.js +6 -0
- package/package.json +4 -4
package/lib/path/conversion.js
CHANGED
@@ -166,7 +166,15 @@ function hoistFunctionEnvironment(fnPath, noNewArrows = true, allowInsertArrow =
|
|
166
166
|
}
|
167
167
|
|
168
168
|
if (argumentsPaths.length > 0) {
|
169
|
-
const argumentsBinding = getBinding(thisEnvFn, "arguments", () =>
|
169
|
+
const argumentsBinding = getBinding(thisEnvFn, "arguments", () => {
|
170
|
+
const args = () => t.identifier("arguments");
|
171
|
+
|
172
|
+
if (thisEnvFn.scope.path.isProgram()) {
|
173
|
+
return t.conditionalExpression(t.binaryExpression("===", t.unaryExpression("typeof", args()), t.stringLiteral("undefined")), thisEnvFn.scope.buildUndefinedNode(), args());
|
174
|
+
} else {
|
175
|
+
return args();
|
176
|
+
}
|
177
|
+
});
|
170
178
|
argumentsPaths.forEach(argumentsChild => {
|
171
179
|
const argsRef = t.identifier(argumentsBinding);
|
172
180
|
argsRef.loc = argumentsChild.node.loc;
|
@@ -398,6 +406,19 @@ function getScopeInformation(fnPath) {
|
|
398
406
|
|
399
407
|
ReferencedIdentifier(child) {
|
400
408
|
if (child.node.name !== "arguments") return;
|
409
|
+
let curr = child.scope;
|
410
|
+
|
411
|
+
do {
|
412
|
+
if (curr.hasOwnBinding("arguments")) {
|
413
|
+
curr.rename("arguments");
|
414
|
+
return;
|
415
|
+
}
|
416
|
+
|
417
|
+
if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {
|
418
|
+
break;
|
419
|
+
}
|
420
|
+
} while (curr = curr.parent);
|
421
|
+
|
401
422
|
argumentsPaths.push(child);
|
402
423
|
},
|
403
424
|
|
package/lib/scope/index.js
CHANGED
@@ -172,11 +172,17 @@ const collectorVisitor = {
|
|
172
172
|
|
173
173
|
Declaration(path) {
|
174
174
|
if (path.isBlockScoped()) return;
|
175
|
+
if (path.isImportDeclaration()) return;
|
175
176
|
if (path.isExportDeclaration()) return;
|
176
177
|
const parent = path.scope.getFunctionParent() || path.scope.getProgramParent();
|
177
178
|
parent.registerDeclaration(path);
|
178
179
|
},
|
179
180
|
|
181
|
+
ImportDeclaration(path) {
|
182
|
+
const parent = path.scope.getBlockParent();
|
183
|
+
parent.registerDeclaration(path);
|
184
|
+
},
|
185
|
+
|
180
186
|
ReferencedIdentifier(path, state) {
|
181
187
|
state.references.push(path);
|
182
188
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.14.
|
3
|
+
"version": "7.14.8",
|
4
4
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
5
5
|
"author": "The Babel Team (https://babel.dev/team)",
|
6
6
|
"homepage": "https://babel.dev/docs/en/next/babel-traverse",
|
@@ -17,12 +17,12 @@
|
|
17
17
|
"main": "./lib/index.js",
|
18
18
|
"dependencies": {
|
19
19
|
"@babel/code-frame": "^7.14.5",
|
20
|
-
"@babel/generator": "^7.14.
|
20
|
+
"@babel/generator": "^7.14.8",
|
21
21
|
"@babel/helper-function-name": "^7.14.5",
|
22
22
|
"@babel/helper-hoist-variables": "^7.14.5",
|
23
23
|
"@babel/helper-split-export-declaration": "^7.14.5",
|
24
|
-
"@babel/parser": "^7.14.
|
25
|
-
"@babel/types": "^7.14.
|
24
|
+
"@babel/parser": "^7.14.8",
|
25
|
+
"@babel/types": "^7.14.8",
|
26
26
|
"debug": "^4.1.0",
|
27
27
|
"globals": "^11.1.0"
|
28
28
|
},
|