@babel/traverse 7.12.13 → 7.12.17

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.

Files changed (2) hide show
  1. package/lib/scope/index.js +17 -29
  2. package/package.json +4 -4
@@ -178,11 +178,7 @@ const collectorVisitor = {
178
178
 
179
179
  Declaration(path) {
180
180
  if (path.isBlockScoped()) return;
181
-
182
- if (path.isExportDeclaration() && path.get("declaration").isDeclaration()) {
183
- return;
184
- }
185
-
181
+ if (path.isExportDeclaration()) return;
186
182
  const parent = path.scope.getFunctionParent() || path.scope.getProgramParent();
187
183
  parent.registerDeclaration(path);
188
184
  },
@@ -205,6 +201,7 @@ const collectorVisitor = {
205
201
  node,
206
202
  scope
207
203
  } = path;
204
+ if (t.isExportAllDeclaration(node)) return;
208
205
  const declar = node.declaration;
209
206
 
210
207
  if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
@@ -225,7 +222,6 @@ const collectorVisitor = {
225
222
  },
226
223
 
227
224
  LabeledStatement(path) {
228
- path.scope.getProgramParent().addGlobal(path.node);
229
225
  path.scope.getBlockParent().registerDeclaration(path);
230
226
  },
231
227
 
@@ -256,16 +252,6 @@ const collectorVisitor = {
256
252
  }
257
253
  },
258
254
 
259
- Block(path) {
260
- const paths = path.get("body");
261
-
262
- for (const bodyPath of paths) {
263
- if (bodyPath.isFunctionDeclaration()) {
264
- path.scope.getBlockParent().registerDeclaration(bodyPath);
265
- }
266
- }
267
- },
268
-
269
255
  CatchClause(path) {
270
256
  path.scope.registerBinding("let", path);
271
257
  },
@@ -722,19 +708,6 @@ class Scope {
722
708
  this.globals = Object.create(null);
723
709
  this.uids = Object.create(null);
724
710
  this.data = Object.create(null);
725
-
726
- if (path.isFunction()) {
727
- if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[t.NOT_LOCAL_BINDING]) {
728
- this.registerBinding("local", path.get("id"), path);
729
- }
730
-
731
- const params = path.get("params");
732
-
733
- for (const param of params) {
734
- this.registerBinding("param", param);
735
- }
736
- }
737
-
738
711
  const programParent = this.getProgramParent();
739
712
  if (programParent.crawling) return;
740
713
  const state = {
@@ -743,6 +716,21 @@ class Scope {
743
716
  assignments: []
744
717
  };
745
718
  this.crawling = true;
719
+
720
+ if (path.type !== "Program" && collectorVisitor._exploded) {
721
+ for (const visit of collectorVisitor.enter) {
722
+ visit(path, state);
723
+ }
724
+
725
+ const typeVisitors = collectorVisitor[path.type];
726
+
727
+ if (typeVisitors) {
728
+ for (const visit of typeVisitors.enter) {
729
+ visit(path, state);
730
+ }
731
+ }
732
+ }
733
+
746
734
  path.traverse(collectorVisitor, state);
747
735
  this.crawling = false;
748
736
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.12.13",
3
+ "version": "7.12.17",
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://babel.dev/docs/en/next/babel-traverse",
@@ -17,11 +17,11 @@
17
17
  "main": "lib/index.js",
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.12.13",
20
- "@babel/generator": "^7.12.13",
20
+ "@babel/generator": "^7.12.17",
21
21
  "@babel/helper-function-name": "^7.12.13",
22
22
  "@babel/helper-split-export-declaration": "^7.12.13",
23
- "@babel/parser": "^7.12.13",
24
- "@babel/types": "^7.12.13",
23
+ "@babel/parser": "^7.12.17",
24
+ "@babel/types": "^7.12.17",
25
25
  "debug": "^4.1.0",
26
26
  "globals": "^11.1.0",
27
27
  "lodash": "^4.17.19"