@babel/traverse 7.6.3 → 7.8.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/context.js CHANGED
@@ -11,7 +11,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
11
11
 
12
12
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
13
 
14
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
package/lib/index.js CHANGED
@@ -44,7 +44,7 @@ var _hub = _interopRequireDefault(require("./hub"));
44
44
 
45
45
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
46
46
 
47
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
48
48
 
49
49
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
50
 
@@ -58,6 +58,10 @@ function traverse(parent, opts, scope, state, parentPath) {
58
58
  }
59
59
  }
60
60
 
61
+ if (!t.VISITOR_KEYS[parent.type]) {
62
+ return;
63
+ }
64
+
61
65
  visitors.explode(opts);
62
66
  traverse.node(parent, opts, scope, state, parentPath);
63
67
  }
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
 
23
23
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
24
24
 
25
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
26
 
27
27
  function findParent(callback) {
28
28
  let path = this;
@@ -11,7 +11,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
11
11
 
12
12
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
13
 
14
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
 
16
16
  function shareCommentsWithSiblings() {
17
17
  if (typeof this.key === "string") return;
@@ -26,6 +26,8 @@ exports._getQueueContexts = _getQueueContexts;
26
26
 
27
27
  var _index = _interopRequireDefault(require("../index"));
28
28
 
29
+ var _index2 = require("./index");
30
+
29
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
32
 
31
33
  function call(key) {
@@ -61,7 +63,7 @@ function _call(fns) {
61
63
  }
62
64
 
63
65
  if (this.node !== node) return true;
64
- if (this.shouldStop || this.shouldSkip || this.removed) return true;
66
+ if (this._traverseFlags > 0) return true;
65
67
  }
66
68
 
67
69
  return false;
@@ -85,7 +87,7 @@ function visit() {
85
87
  return false;
86
88
  }
87
89
 
88
- if (this.call("enter") || this.shouldSkip) {
90
+ if (this.shouldSkip || this.call("enter") || this.shouldSkip) {
89
91
  this.debug("Skip...");
90
92
  return this.shouldStop;
91
93
  }
@@ -103,12 +105,15 @@ function skip() {
103
105
  }
104
106
 
105
107
  function skipKey(key) {
108
+ if (this.skipKeys == null) {
109
+ this.skipKeys = {};
110
+ }
111
+
106
112
  this.skipKeys[key] = true;
107
113
  }
108
114
 
109
115
  function stop() {
110
- this.shouldStop = true;
111
- this.shouldSkip = true;
116
+ this._traverseFlags |= _index2.SHOULD_SKIP | _index2.SHOULD_STOP;
112
117
  }
113
118
 
114
119
  function setScope() {
@@ -127,10 +132,11 @@ function setScope() {
127
132
  }
128
133
 
129
134
  function setContext(context) {
130
- this.shouldSkip = false;
131
- this.shouldStop = false;
132
- this.removed = false;
133
- this.skipKeys = {};
135
+ if (this.skipKeys != null) {
136
+ this.skipKeys = {};
137
+ }
138
+
139
+ this._traverseFlags = 0;
134
140
 
135
141
  if (context) {
136
142
  this.context = context;
@@ -208,9 +214,7 @@ function pushContext(context) {
208
214
  }
209
215
 
210
216
  function setup(parentPath, container, listKey, key) {
211
- this.inList = !!listKey;
212
217
  this.listKey = listKey;
213
- this.parentKey = listKey || key;
214
218
  this.container = container;
215
219
  this.parentPath = parentPath || this.parentPath;
216
220
  this.setKey(key);
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
 
18
18
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
19
19
 
20
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
22
  function toComputedKey() {
23
23
  const node = this.node;
@@ -171,21 +171,6 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
171
171
  });
172
172
  }
173
173
 
174
- let thisBinding;
175
-
176
- if (thisPaths.length > 0 || specCompliant) {
177
- thisBinding = getThisBinding(thisEnvFn, inConstructor);
178
-
179
- if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
180
- thisPaths.forEach(thisChild => {
181
- const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
182
- thisRef.loc = thisChild.node.loc;
183
- thisChild.replaceWith(thisRef);
184
- });
185
- if (specCompliant) thisBinding = null;
186
- }
187
- }
188
-
189
174
  if (argumentsPaths.length > 0) {
190
175
  const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t.identifier("arguments"));
191
176
  argumentsPaths.forEach(argumentsChild => {
@@ -212,41 +197,53 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro
212
197
  const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
213
198
  flatSuperProps.forEach(superProp => {
214
199
  const key = superProp.node.computed ? "" : superProp.get("property").node.name;
215
-
216
- if (superProp.parentPath.isCallExpression({
200
+ const isAssignment = superProp.parentPath.isAssignmentExpression({
201
+ left: superProp.node
202
+ });
203
+ const isCall = superProp.parentPath.isCallExpression({
217
204
  callee: superProp.node
218
- })) {
219
- const superBinding = getSuperPropCallBinding(thisEnvFn, key);
220
-
221
- if (superProp.node.computed) {
222
- const prop = superProp.get("property").node;
223
- superProp.replaceWith(t.identifier(superBinding));
224
- superProp.parentPath.node.arguments.unshift(prop);
225
- } else {
226
- superProp.replaceWith(t.identifier(superBinding));
227
- }
205
+ });
206
+ const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
207
+ const args = [];
208
+
209
+ if (superProp.node.computed) {
210
+ args.push(superProp.get("property").node);
211
+ }
212
+
213
+ if (isAssignment) {
214
+ const value = superProp.parentPath.node.right;
215
+ args.push(value);
216
+ }
217
+
218
+ const call = t.callExpression(t.identifier(superBinding), args);
219
+
220
+ if (isCall) {
221
+ superProp.parentPath.unshiftContainer("arguments", t.thisExpression());
222
+ superProp.replaceWith(t.memberExpression(call, t.identifier("call")));
223
+ thisPaths.push(superProp.parentPath.get("arguments.0"));
224
+ } else if (isAssignment) {
225
+ superProp.parentPath.replaceWith(call);
228
226
  } else {
229
- const isAssignment = superProp.parentPath.isAssignmentExpression({
230
- left: superProp.node
231
- });
232
- const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
233
- const args = [];
234
-
235
- if (superProp.node.computed) {
236
- args.push(superProp.get("property").node);
237
- }
238
-
239
- if (isAssignment) {
240
- const value = superProp.parentPath.node.right;
241
- args.push(value);
242
- superProp.parentPath.replaceWith(t.callExpression(t.identifier(superBinding), args));
243
- } else {
244
- superProp.replaceWith(t.callExpression(t.identifier(superBinding), args));
245
- }
227
+ superProp.replaceWith(call);
246
228
  }
247
229
  });
248
230
  }
249
231
 
232
+ let thisBinding;
233
+
234
+ if (thisPaths.length > 0 || specCompliant) {
235
+ thisBinding = getThisBinding(thisEnvFn, inConstructor);
236
+
237
+ if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
238
+ thisPaths.forEach(thisChild => {
239
+ const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
240
+ thisRef.loc = thisChild.node.loc;
241
+ thisChild.replaceWith(thisRef);
242
+ });
243
+ if (specCompliant) thisBinding = null;
244
+ }
245
+ }
246
+
250
247
  return thisBinding;
251
248
  }
252
249
 
@@ -322,24 +319,6 @@ function getSuperBinding(thisEnvFn) {
322
319
  });
323
320
  }
324
321
 
325
- function getSuperPropCallBinding(thisEnvFn, propName) {
326
- return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => {
327
- const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
328
- const argsList = [t.restElement(argsBinding)];
329
- let fnBody;
330
-
331
- if (propName) {
332
- fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(propName)), [t.spreadElement(t.identifier(argsBinding.name))]);
333
- } else {
334
- const method = thisEnvFn.scope.generateUidIdentifier("prop");
335
- argsList.unshift(method);
336
- fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(method.name), true), [t.spreadElement(t.identifier(argsBinding.name))]);
337
- }
338
-
339
- return t.arrowFunctionExpression(argsList, fnBody);
340
- });
341
- }
342
-
343
322
  function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
344
323
  const op = isAssignment ? "set" : "get";
345
324
  return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => {
@@ -24,7 +24,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
24
24
 
25
25
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
26
26
 
27
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
28
 
29
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
30
 
package/lib/path/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.SHOULD_SKIP = exports.SHOULD_STOP = exports.REMOVED = void 0;
7
7
 
8
8
  var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types"));
9
9
 
@@ -45,19 +45,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
45
45
 
46
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
47
47
 
48
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
48
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
49
 
50
50
  const debug = (0, _debug.default)("babel");
51
+ const REMOVED = 1 << 0;
52
+ exports.REMOVED = REMOVED;
53
+ const SHOULD_STOP = 1 << 1;
54
+ exports.SHOULD_STOP = SHOULD_STOP;
55
+ const SHOULD_SKIP = 1 << 2;
56
+ exports.SHOULD_SKIP = SHOULD_SKIP;
51
57
 
52
58
  class NodePath {
53
59
  constructor(hub, parent) {
54
60
  this.parent = parent;
55
61
  this.hub = hub;
56
62
  this.contexts = [];
57
- this.data = Object.create(null);
58
- this.shouldSkip = false;
59
- this.shouldStop = false;
60
- this.removed = false;
63
+ this.data = null;
64
+ this._traverseFlags = 0;
61
65
  this.state = null;
62
66
  this.opts = null;
63
67
  this.skipKeys = null;
@@ -65,13 +69,10 @@ class NodePath {
65
69
  this.context = null;
66
70
  this.container = null;
67
71
  this.listKey = null;
68
- this.inList = false;
69
- this.parentKey = null;
70
72
  this.key = null;
71
73
  this.node = null;
72
74
  this.scope = null;
73
75
  this.type = null;
74
- this.typeAnnotation = null;
75
76
  }
76
77
 
77
78
  static get({
@@ -122,10 +123,18 @@ class NodePath {
122
123
  }
123
124
 
124
125
  setData(key, val) {
126
+ if (this.data == null) {
127
+ this.data = Object.create(null);
128
+ }
129
+
125
130
  return this.data[key] = val;
126
131
  }
127
132
 
128
133
  getData(key, def) {
134
+ if (this.data == null) {
135
+ this.data = Object.create(null);
136
+ }
137
+
129
138
  let val = this.data[key];
130
139
  if (val === undefined && def !== undefined) val = this.data[key] = def;
131
140
  return val;
@@ -166,6 +175,56 @@ class NodePath {
166
175
  return (0, _generator.default)(this.node).code;
167
176
  }
168
177
 
178
+ get inList() {
179
+ return !!this.listKey;
180
+ }
181
+
182
+ set inList(inList) {
183
+ if (!inList) {
184
+ this.listKey = null;
185
+ }
186
+ }
187
+
188
+ get parentKey() {
189
+ return this.listKey || this.key;
190
+ }
191
+
192
+ get shouldSkip() {
193
+ return !!(this._traverseFlags & SHOULD_SKIP);
194
+ }
195
+
196
+ set shouldSkip(v) {
197
+ if (v) {
198
+ this._traverseFlags |= SHOULD_SKIP;
199
+ } else {
200
+ this._traverseFlags &= ~SHOULD_SKIP;
201
+ }
202
+ }
203
+
204
+ get shouldStop() {
205
+ return !!(this._traverseFlags & SHOULD_STOP);
206
+ }
207
+
208
+ set shouldStop(v) {
209
+ if (v) {
210
+ this._traverseFlags |= SHOULD_STOP;
211
+ } else {
212
+ this._traverseFlags &= ~SHOULD_STOP;
213
+ }
214
+ }
215
+
216
+ get removed() {
217
+ return !!(this._traverseFlags & REMOVED);
218
+ }
219
+
220
+ set removed(v) {
221
+ if (v) {
222
+ this._traverseFlags |= REMOVED;
223
+ } else {
224
+ this._traverseFlags &= ~REMOVED;
225
+ }
226
+ }
227
+
169
228
  }
170
229
 
171
230
  exports.default = NodePath;
@@ -16,7 +16,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
16
16
 
17
17
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
18
18
 
19
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
20
 
21
21
  function getTypeAnnotation() {
22
22
  if (this.typeAnnotation) return this.typeAnnotation;
@@ -9,7 +9,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
9
9
 
10
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
11
 
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
14
  function _default(node) {
15
15
  if (!this.isReferenced()) return;
@@ -41,7 +41,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
41
 
42
42
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
43
43
 
44
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
45
 
46
46
  function VariableDeclarator() {
47
47
  const id = this.get("id");
@@ -30,7 +30,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
30
30
 
31
31
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
32
32
 
33
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
34
34
 
35
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
36
 
@@ -9,7 +9,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
9
9
 
10
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
11
 
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
14
  const referenceVisitor = {
15
15
  ReferencedIdentifier(path, state) {
@@ -9,7 +9,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
9
9
 
10
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11
11
 
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
14
  const ReferencedIdentifier = {
15
15
  types: ["Identifier", "JSXIdentifier"],
@@ -98,7 +98,7 @@ const Expression = {
98
98
  };
99
99
  exports.Expression = Expression;
100
100
  const Scope = {
101
- types: ["Scopable"],
101
+ types: ["Scopable", "Pattern"],
102
102
 
103
103
  checkPath(path) {
104
104
  return t.isScope(path.node, path.parent);
@@ -24,7 +24,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
24
24
 
25
25
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
26
26
 
27
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
28
 
29
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
30
 
@@ -101,7 +101,7 @@ function insertAfter(nodes) {
101
101
  return parentPath.insertAfter(nodes.map(node => {
102
102
  return t.isExpression(node) ? t.expressionStatement(node) : node;
103
103
  }));
104
- } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
104
+ } else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
105
105
  if (this.node) {
106
106
  let {
107
107
  scope
@@ -12,6 +12,8 @@ exports._assertUnremoved = _assertUnremoved;
12
12
 
13
13
  var _removalHooks = require("./lib/removal-hooks");
14
14
 
15
+ var _index = require("./index");
16
+
15
17
  function remove() {
16
18
  this._assertUnremoved();
17
19
 
@@ -53,8 +55,7 @@ function _remove() {
53
55
  }
54
56
 
55
57
  function _markRemoved() {
56
- this.shouldSkip = true;
57
- this.removed = true;
58
+ this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
58
59
  this.node = null;
59
60
  }
60
61
 
@@ -22,7 +22,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
22
22
 
23
23
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
24
24
 
25
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
26
 
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
28
 
@@ -25,7 +25,7 @@ var _cache = require("../cache");
25
25
 
26
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
27
27
 
28
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
31
 
@@ -774,10 +774,18 @@ class Scope {
774
774
 
775
775
  getBinding(name) {
776
776
  let scope = this;
777
+ let previousPath;
777
778
 
778
779
  do {
779
780
  const binding = scope.getOwnBinding(name);
780
- if (binding) return binding;
781
+
782
+ if (binding) {
783
+ if (previousPath && previousPath.isPattern() && previousPath.parentPath.isFunction() && binding.kind !== "param") {} else {
784
+ return binding;
785
+ }
786
+ }
787
+
788
+ previousPath = scope.path;
781
789
  } while (scope = scope.parent);
782
790
  }
783
791
 
@@ -13,7 +13,7 @@ var t = _interopRequireWildcard(require("@babel/types"));
13
13
 
14
14
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
15
15
 
16
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
package/lib/visitors.js CHANGED
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
 
18
18
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
19
19
 
20
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
22
  function explode(visitor) {
23
23
  if (visitor._exploded) return visitor;
@@ -184,6 +184,10 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
184
184
  newFn = wrapper(state.key, key, newFn);
185
185
  }
186
186
 
187
+ if (newFn !== fn) {
188
+ newFn.toString = () => fn.toString();
189
+ }
190
+
187
191
  return newFn;
188
192
  });
189
193
  newVisitor[key] = fns;
package/package.json CHANGED
@@ -1,28 +1,29 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.6.3",
3
+ "version": "7.8.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/",
7
7
  "license": "MIT",
8
+ "type": "commonjs",
8
9
  "publishConfig": {
9
10
  "access": "public"
10
11
  },
11
12
  "repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
12
13
  "main": "lib/index.js",
13
14
  "dependencies": {
14
- "@babel/code-frame": "^7.5.5",
15
- "@babel/generator": "^7.6.3",
16
- "@babel/helper-function-name": "^7.1.0",
17
- "@babel/helper-split-export-declaration": "^7.4.4",
18
- "@babel/parser": "^7.6.3",
19
- "@babel/types": "^7.6.3",
15
+ "@babel/code-frame": "^7.8.0",
16
+ "@babel/generator": "^7.8.0",
17
+ "@babel/helper-function-name": "^7.8.0",
18
+ "@babel/helper-split-export-declaration": "^7.8.0",
19
+ "@babel/parser": "^7.8.0",
20
+ "@babel/types": "^7.8.0",
20
21
  "debug": "^4.1.0",
21
22
  "globals": "^11.1.0",
22
23
  "lodash": "^4.17.13"
23
24
  },
24
25
  "devDependencies": {
25
- "@babel/helper-plugin-test-runner": "^7.0.0"
26
+ "@babel/helper-plugin-test-runner": "^7.8.0"
26
27
  },
27
- "gitHead": "d329156ebc17da01382acb83e212cb4328534ebc"
28
+ "gitHead": "2486615a74580283c49475d66067bd7fcab3330e"
28
29
  }