@babel/traverse 7.15.0 → 7.16.5

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.

@@ -9,8 +9,16 @@ var _binding = require("../binding");
9
9
 
10
10
  var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration");
11
11
 
12
- var t = require("@babel/types");
13
-
12
+ var _t = require("@babel/types");
13
+
14
+ const {
15
+ VISITOR_KEYS,
16
+ assignmentExpression,
17
+ identifier,
18
+ toExpression,
19
+ variableDeclaration,
20
+ variableDeclarator
21
+ } = _t;
14
22
  const renameVisitor = {
15
23
  ReferencedIdentifier({
16
24
  node
@@ -62,20 +70,20 @@ class Renamer {
62
70
  return;
63
71
  if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
64
72
  if (this.binding.kind !== "hoisted") return;
65
- path.node.id = t.identifier(this.oldName);
73
+ path.node.id = identifier(this.oldName);
66
74
  path.node._blockHoist = 3;
67
- path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(this.newName), t.toExpression(path.node))]));
75
+ path.replaceWith(variableDeclaration("let", [variableDeclarator(identifier(this.newName), toExpression(path.node))]));
68
76
  }
69
77
 
70
78
  maybeConvertFromClassFunctionExpression(path) {
71
79
  return;
72
80
  if (!path.isFunctionExpression() && !path.isClassExpression()) return;
73
81
  if (this.binding.kind !== "local") return;
74
- path.node.id = t.identifier(this.oldName);
82
+ path.node.id = identifier(this.oldName);
75
83
  this.binding.scope.parent.push({
76
- id: t.identifier(this.newName)
84
+ id: identifier(this.newName)
77
85
  });
78
- path.replaceWith(t.assignmentExpression("=", t.identifier(this.newName), path.node));
86
+ path.replaceWith(assignmentExpression("=", identifier(this.newName), path.node));
79
87
  }
80
88
 
81
89
  rename(block) {
@@ -130,7 +138,7 @@ function skipAllButComputedMethodKey(path) {
130
138
  return;
131
139
  }
132
140
 
133
- const keys = t.VISITOR_KEYS[path.type];
141
+ const keys = VISITOR_KEYS[path.type];
134
142
 
135
143
  for (const key of keys) {
136
144
  if (key !== "key") path.skipKey(key);
package/lib/types.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var t = require("@babel/types");
4
-
5
3
  var _index = require("./index");
6
4
 
7
5
  var _virtualTypes = require("./path/generated/virtual-types");
package/lib/visitors.js CHANGED
@@ -4,12 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.explode = explode;
7
- exports.verify = verify;
8
7
  exports.merge = merge;
8
+ exports.verify = verify;
9
9
 
10
10
  var virtualTypes = require("./path/lib/virtual-types");
11
11
 
12
- var t = require("@babel/types");
12
+ var _t = require("@babel/types");
13
+
14
+ const {
15
+ DEPRECATED_KEYS,
16
+ FLIPPED_ALIAS_KEYS,
17
+ TYPES
18
+ } = _t;
13
19
 
14
20
  function explode(visitor) {
15
21
  if (visitor._exploded) return visitor;
@@ -60,8 +66,8 @@ function explode(visitor) {
60
66
  for (const nodeType of Object.keys(visitor)) {
61
67
  if (shouldIgnoreKey(nodeType)) continue;
62
68
  const fns = visitor[nodeType];
63
- let aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
64
- const deprecatedKey = t.DEPRECATED_KEYS[nodeType];
69
+ let aliases = FLIPPED_ALIAS_KEYS[nodeType];
70
+ const deprecatedKey = DEPRECATED_KEYS[nodeType];
65
71
 
66
72
  if (deprecatedKey) {
67
73
  console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`);
@@ -104,7 +110,7 @@ function verify(visitor) {
104
110
 
105
111
  if (shouldIgnoreKey(nodeType)) continue;
106
112
 
107
- if (t.TYPES.indexOf(nodeType) < 0) {
113
+ if (TYPES.indexOf(nodeType) < 0) {
108
114
  throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
109
115
  }
110
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.15.0",
3
+ "version": "7.16.5",
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",
@@ -16,18 +16,19 @@
16
16
  },
17
17
  "main": "./lib/index.js",
18
18
  "dependencies": {
19
- "@babel/code-frame": "^7.14.5",
20
- "@babel/generator": "^7.15.0",
21
- "@babel/helper-function-name": "^7.14.5",
22
- "@babel/helper-hoist-variables": "^7.14.5",
23
- "@babel/helper-split-export-declaration": "^7.14.5",
24
- "@babel/parser": "^7.15.0",
25
- "@babel/types": "^7.15.0",
19
+ "@babel/code-frame": "^7.16.0",
20
+ "@babel/generator": "^7.16.5",
21
+ "@babel/helper-environment-visitor": "^7.16.5",
22
+ "@babel/helper-function-name": "^7.16.0",
23
+ "@babel/helper-hoist-variables": "^7.16.0",
24
+ "@babel/helper-split-export-declaration": "^7.16.0",
25
+ "@babel/parser": "^7.16.5",
26
+ "@babel/types": "^7.16.0",
26
27
  "debug": "^4.1.0",
27
28
  "globals": "^11.1.0"
28
29
  },
29
30
  "devDependencies": {
30
- "@babel/helper-plugin-test-runner": "7.14.5"
31
+ "@babel/helper-plugin-test-runner": "^7.16.5"
31
32
  },
32
33
  "engines": {
33
34
  "node": ">=6.9.0"