@babel/traverse 7.5.0 → 7.6.3
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 +4 -10
- package/lib/index.js +10 -24
- package/lib/path/ancestry.js +5 -11
- package/lib/path/comments.js +5 -11
- package/lib/path/conversion.js +40 -54
- package/lib/path/family.js +59 -13
- package/lib/path/index.js +12 -34
- package/lib/path/inference/index.js +20 -26
- package/lib/path/inference/inferer-reference.js +11 -17
- package/lib/path/inference/inferers.js +40 -46
- package/lib/path/introspection.js +122 -70
- package/lib/path/lib/hoister.js +19 -14
- package/lib/path/lib/virtual-types.js +22 -28
- package/lib/path/modification.js +8 -14
- package/lib/path/replacement.js +27 -49
- package/lib/scope/index.js +62 -104
- package/lib/scope/lib/renamer.js +10 -24
- package/lib/visitors.js +9 -23
- package/package.json +7 -7
package/lib/scope/index.js
CHANGED
@@ -5,70 +5,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
|
9
|
-
const data = _interopRequireDefault(require("lodash/includes"));
|
8
|
+
var _includes = _interopRequireDefault(require("lodash/includes"));
|
10
9
|
|
11
|
-
|
12
|
-
return data;
|
13
|
-
};
|
14
|
-
|
15
|
-
return data;
|
16
|
-
}
|
17
|
-
|
18
|
-
function _repeat() {
|
19
|
-
const data = _interopRequireDefault(require("lodash/repeat"));
|
20
|
-
|
21
|
-
_repeat = function () {
|
22
|
-
return data;
|
23
|
-
};
|
24
|
-
|
25
|
-
return data;
|
26
|
-
}
|
10
|
+
var _repeat = _interopRequireDefault(require("lodash/repeat"));
|
27
11
|
|
28
12
|
var _renamer = _interopRequireDefault(require("./lib/renamer"));
|
29
13
|
|
30
14
|
var _index = _interopRequireDefault(require("../index"));
|
31
15
|
|
32
|
-
|
33
|
-
const data = _interopRequireDefault(require("lodash/defaults"));
|
34
|
-
|
35
|
-
_defaults = function () {
|
36
|
-
return data;
|
37
|
-
};
|
38
|
-
|
39
|
-
return data;
|
40
|
-
}
|
16
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
41
17
|
|
42
18
|
var _binding = _interopRequireDefault(require("./binding"));
|
43
19
|
|
44
|
-
|
45
|
-
const data = _interopRequireDefault(require("globals"));
|
20
|
+
var _globals = _interopRequireDefault(require("globals"));
|
46
21
|
|
47
|
-
|
48
|
-
return data;
|
49
|
-
};
|
50
|
-
|
51
|
-
return data;
|
52
|
-
}
|
53
|
-
|
54
|
-
function t() {
|
55
|
-
const data = _interopRequireWildcard(require("@babel/types"));
|
56
|
-
|
57
|
-
t = function () {
|
58
|
-
return data;
|
59
|
-
};
|
60
|
-
|
61
|
-
return data;
|
62
|
-
}
|
22
|
+
var t = _interopRequireWildcard(require("@babel/types"));
|
63
23
|
|
64
24
|
var _cache = require("../cache");
|
65
25
|
|
66
|
-
function
|
26
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
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; }
|
67
29
|
|
68
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
69
31
|
|
70
32
|
function gatherNodeParts(node, parts) {
|
71
|
-
if (t
|
33
|
+
if (t.isModuleDeclaration(node)) {
|
72
34
|
if (node.source) {
|
73
35
|
gatherNodeParts(node.source, parts);
|
74
36
|
} else if (node.specifiers && node.specifiers.length) {
|
@@ -78,33 +40,33 @@ function gatherNodeParts(node, parts) {
|
|
78
40
|
} else if (node.declaration) {
|
79
41
|
gatherNodeParts(node.declaration, parts);
|
80
42
|
}
|
81
|
-
} else if (t
|
43
|
+
} else if (t.isModuleSpecifier(node)) {
|
82
44
|
gatherNodeParts(node.local, parts);
|
83
|
-
} else if (t
|
45
|
+
} else if (t.isMemberExpression(node)) {
|
84
46
|
gatherNodeParts(node.object, parts);
|
85
47
|
gatherNodeParts(node.property, parts);
|
86
|
-
} else if (t
|
48
|
+
} else if (t.isIdentifier(node)) {
|
87
49
|
parts.push(node.name);
|
88
|
-
} else if (t
|
50
|
+
} else if (t.isLiteral(node)) {
|
89
51
|
parts.push(node.value);
|
90
|
-
} else if (t
|
52
|
+
} else if (t.isCallExpression(node)) {
|
91
53
|
gatherNodeParts(node.callee, parts);
|
92
|
-
} else if (t
|
54
|
+
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
|
93
55
|
for (const prop of node.properties) {
|
94
56
|
gatherNodeParts(prop.key || prop.argument, parts);
|
95
57
|
}
|
96
|
-
} else if (t
|
58
|
+
} else if (t.isPrivateName(node)) {
|
97
59
|
gatherNodeParts(node.id, parts);
|
98
|
-
} else if (t
|
60
|
+
} else if (t.isThisExpression(node)) {
|
99
61
|
parts.push("this");
|
100
|
-
} else if (t
|
62
|
+
} else if (t.isSuper(node)) {
|
101
63
|
parts.push("super");
|
102
64
|
}
|
103
65
|
}
|
104
66
|
|
105
67
|
const collectorVisitor = {
|
106
68
|
For(path) {
|
107
|
-
for (const key of t
|
69
|
+
for (const key of t.FOR_INIT_KEYS) {
|
108
70
|
const declar = path.get(key);
|
109
71
|
|
110
72
|
if (declar.isVar()) {
|
@@ -145,14 +107,14 @@ const collectorVisitor = {
|
|
145
107
|
} = path;
|
146
108
|
const declar = node.declaration;
|
147
109
|
|
148
|
-
if (t
|
110
|
+
if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
|
149
111
|
const id = declar.id;
|
150
112
|
if (!id) return;
|
151
113
|
const binding = scope.getBinding(id.name);
|
152
114
|
if (binding) binding.reference(path);
|
153
|
-
} else if (t
|
115
|
+
} else if (t.isVariableDeclaration(declar)) {
|
154
116
|
for (const decl of declar.declarations) {
|
155
|
-
for (const name of Object.keys(t
|
117
|
+
for (const name of Object.keys(t.getBindingIdentifiers(decl))) {
|
156
118
|
const binding = scope.getBinding(name);
|
157
119
|
if (binding) binding.reference(path);
|
158
120
|
}
|
@@ -249,15 +211,15 @@ class Scope {
|
|
249
211
|
this.push({
|
250
212
|
id
|
251
213
|
});
|
252
|
-
return t
|
214
|
+
return t.cloneNode(id);
|
253
215
|
}
|
254
216
|
|
255
217
|
generateUidIdentifier(name) {
|
256
|
-
return t
|
218
|
+
return t.identifier(this.generateUid(name));
|
257
219
|
}
|
258
220
|
|
259
221
|
generateUid(name = "temp") {
|
260
|
-
name = t
|
222
|
+
name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
|
261
223
|
let uid;
|
262
224
|
let i = 0;
|
263
225
|
|
@@ -281,11 +243,11 @@ class Scope {
|
|
281
243
|
generateUidBasedOnNode(parent, defaultName) {
|
282
244
|
let node = parent;
|
283
245
|
|
284
|
-
if (t
|
246
|
+
if (t.isAssignmentExpression(parent)) {
|
285
247
|
node = parent.left;
|
286
|
-
} else if (t
|
248
|
+
} else if (t.isVariableDeclarator(parent)) {
|
287
249
|
node = parent.id;
|
288
|
-
} else if (t
|
250
|
+
} else if (t.isObjectProperty(node) || t.isObjectMethod(node)) {
|
289
251
|
node = node.key;
|
290
252
|
}
|
291
253
|
|
@@ -297,15 +259,15 @@ class Scope {
|
|
297
259
|
}
|
298
260
|
|
299
261
|
generateUidIdentifierBasedOnNode(parent, defaultName) {
|
300
|
-
return t
|
262
|
+
return t.identifier(this.generateUidBasedOnNode(parent, defaultName));
|
301
263
|
}
|
302
264
|
|
303
265
|
isStatic(node) {
|
304
|
-
if (t
|
266
|
+
if (t.isThisExpression(node) || t.isSuper(node)) {
|
305
267
|
return true;
|
306
268
|
}
|
307
269
|
|
308
|
-
if (t
|
270
|
+
if (t.isIdentifier(node)) {
|
309
271
|
const binding = this.getBinding(node.name);
|
310
272
|
|
311
273
|
if (binding) {
|
@@ -328,7 +290,7 @@ class Scope {
|
|
328
290
|
this.push({
|
329
291
|
id
|
330
292
|
});
|
331
|
-
return t
|
293
|
+
return t.cloneNode(id);
|
332
294
|
}
|
333
295
|
|
334
296
|
return id;
|
@@ -362,7 +324,7 @@ class Scope {
|
|
362
324
|
}
|
363
325
|
|
364
326
|
dump() {
|
365
|
-
const sep = (0, _repeat
|
327
|
+
const sep = (0, _repeat.default)("-", 60);
|
366
328
|
console.log(sep);
|
367
329
|
let scope = this;
|
368
330
|
|
@@ -384,7 +346,7 @@ class Scope {
|
|
384
346
|
}
|
385
347
|
|
386
348
|
toArray(node, i) {
|
387
|
-
if (t
|
349
|
+
if (t.isIdentifier(node)) {
|
388
350
|
const binding = this.getBinding(node.name);
|
389
351
|
|
390
352
|
if (binding && binding.constant && binding.path.isGenericType("Array")) {
|
@@ -392,14 +354,14 @@ class Scope {
|
|
392
354
|
}
|
393
355
|
}
|
394
356
|
|
395
|
-
if (t
|
357
|
+
if (t.isArrayExpression(node)) {
|
396
358
|
return node;
|
397
359
|
}
|
398
360
|
|
399
|
-
if (t
|
361
|
+
if (t.isIdentifier(node, {
|
400
362
|
name: "arguments"
|
401
363
|
})) {
|
402
|
-
return t
|
364
|
+
return t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("Array"), t.identifier("prototype")), t.identifier("slice")), t.identifier("call")), [node]);
|
403
365
|
}
|
404
366
|
|
405
367
|
let helperName;
|
@@ -408,13 +370,13 @@ class Scope {
|
|
408
370
|
if (i === true) {
|
409
371
|
helperName = "toConsumableArray";
|
410
372
|
} else if (i) {
|
411
|
-
args.push(t
|
373
|
+
args.push(t.numericLiteral(i));
|
412
374
|
helperName = "slicedToArray";
|
413
375
|
} else {
|
414
376
|
helperName = "toArray";
|
415
377
|
}
|
416
378
|
|
417
|
-
return t
|
379
|
+
return t.callExpression(this.hub.addHelper(helperName), args);
|
418
380
|
}
|
419
381
|
|
420
382
|
hasLabel(name) {
|
@@ -460,11 +422,7 @@ class Scope {
|
|
460
422
|
}
|
461
423
|
|
462
424
|
buildUndefinedNode() {
|
463
|
-
|
464
|
-
return t().unaryExpression("void", t().numericLiteral(0), true);
|
465
|
-
} else {
|
466
|
-
return t().identifier("undefined");
|
467
|
-
}
|
425
|
+
return t.unaryExpression("void", t.numericLiteral(0), true);
|
468
426
|
}
|
469
427
|
|
470
428
|
registerConstantViolation(path) {
|
@@ -552,56 +510,56 @@ class Scope {
|
|
552
510
|
}
|
553
511
|
|
554
512
|
isPure(node, constantsOnly) {
|
555
|
-
if (t
|
513
|
+
if (t.isIdentifier(node)) {
|
556
514
|
const binding = this.getBinding(node.name);
|
557
515
|
if (!binding) return false;
|
558
516
|
if (constantsOnly) return binding.constant;
|
559
517
|
return true;
|
560
|
-
} else if (t
|
518
|
+
} else if (t.isClass(node)) {
|
561
519
|
if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {
|
562
520
|
return false;
|
563
521
|
}
|
564
522
|
|
565
523
|
return this.isPure(node.body, constantsOnly);
|
566
|
-
} else if (t
|
524
|
+
} else if (t.isClassBody(node)) {
|
567
525
|
for (const method of node.body) {
|
568
526
|
if (!this.isPure(method, constantsOnly)) return false;
|
569
527
|
}
|
570
528
|
|
571
529
|
return true;
|
572
|
-
} else if (t
|
530
|
+
} else if (t.isBinary(node)) {
|
573
531
|
return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
|
574
|
-
} else if (t
|
532
|
+
} else if (t.isArrayExpression(node)) {
|
575
533
|
for (const elem of node.elements) {
|
576
534
|
if (!this.isPure(elem, constantsOnly)) return false;
|
577
535
|
}
|
578
536
|
|
579
537
|
return true;
|
580
|
-
} else if (t
|
538
|
+
} else if (t.isObjectExpression(node)) {
|
581
539
|
for (const prop of node.properties) {
|
582
540
|
if (!this.isPure(prop, constantsOnly)) return false;
|
583
541
|
}
|
584
542
|
|
585
543
|
return true;
|
586
|
-
} else if (t
|
544
|
+
} else if (t.isClassMethod(node)) {
|
587
545
|
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
|
588
546
|
if (node.kind === "get" || node.kind === "set") return false;
|
589
547
|
return true;
|
590
|
-
} else if (t
|
548
|
+
} else if (t.isProperty(node)) {
|
591
549
|
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
|
592
550
|
return this.isPure(node.value, constantsOnly);
|
593
|
-
} else if (t
|
551
|
+
} else if (t.isUnaryExpression(node)) {
|
594
552
|
return this.isPure(node.argument, constantsOnly);
|
595
|
-
} else if (t
|
596
|
-
return t
|
597
|
-
} else if (t
|
553
|
+
} else if (t.isTaggedTemplateExpression(node)) {
|
554
|
+
return t.matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
|
555
|
+
} else if (t.isTemplateLiteral(node)) {
|
598
556
|
for (const expression of node.expressions) {
|
599
557
|
if (!this.isPure(expression, constantsOnly)) return false;
|
600
558
|
}
|
601
559
|
|
602
560
|
return true;
|
603
561
|
} else {
|
604
|
-
return t
|
562
|
+
return t.isPureish(node);
|
605
563
|
}
|
606
564
|
}
|
607
565
|
|
@@ -640,20 +598,20 @@ class Scope {
|
|
640
598
|
this.data = Object.create(null);
|
641
599
|
|
642
600
|
if (path.isLoop()) {
|
643
|
-
for (const key of t
|
601
|
+
for (const key of t.FOR_INIT_KEYS) {
|
644
602
|
const node = path.get(key);
|
645
603
|
if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
|
646
604
|
}
|
647
605
|
}
|
648
606
|
|
649
607
|
if (path.isFunctionExpression() && path.has("id")) {
|
650
|
-
if (!path.get("id").node[t
|
608
|
+
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
|
651
609
|
this.registerBinding("local", path.get("id"), path);
|
652
610
|
}
|
653
611
|
}
|
654
612
|
|
655
613
|
if (path.isClassExpression() && path.has("id")) {
|
656
|
-
if (!path.get("id").node[t
|
614
|
+
if (!path.get("id").node[t.NOT_LOCAL_BINDING]) {
|
657
615
|
this.registerBinding("local", path);
|
658
616
|
}
|
659
617
|
}
|
@@ -732,13 +690,13 @@ class Scope {
|
|
732
690
|
let declarPath = !unique && path.getData(dataKey);
|
733
691
|
|
734
692
|
if (!declarPath) {
|
735
|
-
const declar = t
|
693
|
+
const declar = t.variableDeclaration(kind, []);
|
736
694
|
declar._blockHoist = blockHoist;
|
737
695
|
[declarPath] = path.unshiftContainer("body", [declar]);
|
738
696
|
if (!unique) path.setData(dataKey, declarPath);
|
739
697
|
}
|
740
698
|
|
741
|
-
const declarator = t
|
699
|
+
const declarator = t.variableDeclarator(opts.id, opts.init);
|
742
700
|
declarPath.node.declarations.push(declarator);
|
743
701
|
this.registerBinding(kind, declarPath.get("declarations").pop());
|
744
702
|
}
|
@@ -784,7 +742,7 @@ class Scope {
|
|
784
742
|
let scope = this;
|
785
743
|
|
786
744
|
do {
|
787
|
-
(0, _defaults
|
745
|
+
(0, _defaults.default)(ids, scope.bindings);
|
788
746
|
scope = scope.parent;
|
789
747
|
} while (scope);
|
790
748
|
|
@@ -846,8 +804,8 @@ class Scope {
|
|
846
804
|
if (this.hasOwnBinding(name)) return true;
|
847
805
|
if (this.parentHasBinding(name, noGlobals)) return true;
|
848
806
|
if (this.hasUid(name)) return true;
|
849
|
-
if (!noGlobals && (0, _includes
|
850
|
-
if (!noGlobals && (0, _includes
|
807
|
+
if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true;
|
808
|
+
if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true;
|
851
809
|
return false;
|
852
810
|
}
|
853
811
|
|
@@ -888,5 +846,5 @@ class Scope {
|
|
888
846
|
}
|
889
847
|
|
890
848
|
exports.default = Scope;
|
891
|
-
Scope.globals = Object.keys(_globals
|
849
|
+
Scope.globals = Object.keys(_globals.default.builtin);
|
892
850
|
Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
|
package/lib/scope/lib/renamer.js
CHANGED
@@ -7,27 +7,13 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _binding = _interopRequireDefault(require("../binding"));
|
9
9
|
|
10
|
-
|
11
|
-
const data = _interopRequireDefault(require("@babel/helper-split-export-declaration"));
|
10
|
+
var _helperSplitExportDeclaration = _interopRequireDefault(require("@babel/helper-split-export-declaration"));
|
12
11
|
|
13
|
-
|
14
|
-
return data;
|
15
|
-
};
|
12
|
+
var t = _interopRequireWildcard(require("@babel/types"));
|
16
13
|
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
-
function t() {
|
21
|
-
const data = _interopRequireWildcard(require("@babel/types"));
|
22
|
-
|
23
|
-
t = function () {
|
24
|
-
return data;
|
25
|
-
};
|
26
|
-
|
27
|
-
return data;
|
28
|
-
}
|
14
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
29
15
|
|
30
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; }
|
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; }
|
31
17
|
|
32
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
19
|
|
@@ -74,27 +60,27 @@ class Renamer {
|
|
74
60
|
return;
|
75
61
|
}
|
76
62
|
|
77
|
-
(0, _helperSplitExportDeclaration
|
63
|
+
(0, _helperSplitExportDeclaration.default)(maybeExportDeclar);
|
78
64
|
}
|
79
65
|
|
80
66
|
maybeConvertFromClassFunctionDeclaration(path) {
|
81
67
|
return;
|
82
68
|
if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
|
83
69
|
if (this.binding.kind !== "hoisted") return;
|
84
|
-
path.node.id = t
|
70
|
+
path.node.id = t.identifier(this.oldName);
|
85
71
|
path.node._blockHoist = 3;
|
86
|
-
path.replaceWith(t
|
72
|
+
path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(this.newName), t.toExpression(path.node))]));
|
87
73
|
}
|
88
74
|
|
89
75
|
maybeConvertFromClassFunctionExpression(path) {
|
90
76
|
return;
|
91
77
|
if (!path.isFunctionExpression() && !path.isClassExpression()) return;
|
92
78
|
if (this.binding.kind !== "local") return;
|
93
|
-
path.node.id = t
|
79
|
+
path.node.id = t.identifier(this.oldName);
|
94
80
|
this.binding.scope.parent.push({
|
95
|
-
id: t
|
81
|
+
id: t.identifier(this.newName)
|
96
82
|
});
|
97
|
-
path.replaceWith(t
|
83
|
+
path.replaceWith(t.assignmentExpression("=", t.identifier(this.newName), path.node));
|
98
84
|
}
|
99
85
|
|
100
86
|
rename(block) {
|
package/lib/visitors.js
CHANGED
@@ -9,29 +9,15 @@ exports.merge = merge;
|
|
9
9
|
|
10
10
|
var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
|
11
11
|
|
12
|
-
|
13
|
-
const data = _interopRequireWildcard(require("@babel/types"));
|
12
|
+
var t = _interopRequireWildcard(require("@babel/types"));
|
14
13
|
|
15
|
-
|
16
|
-
return data;
|
17
|
-
};
|
18
|
-
|
19
|
-
return data;
|
20
|
-
}
|
21
|
-
|
22
|
-
function _clone() {
|
23
|
-
const data = _interopRequireDefault(require("lodash/clone"));
|
24
|
-
|
25
|
-
_clone = function () {
|
26
|
-
return data;
|
27
|
-
};
|
28
|
-
|
29
|
-
return data;
|
30
|
-
}
|
14
|
+
var _clone = _interopRequireDefault(require("lodash/clone"));
|
31
15
|
|
32
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
17
|
|
34
|
-
function
|
18
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
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; }
|
35
21
|
|
36
22
|
function explode(visitor) {
|
37
23
|
if (visitor._exploded) return visitor;
|
@@ -82,8 +68,8 @@ function explode(visitor) {
|
|
82
68
|
for (const nodeType of Object.keys(visitor)) {
|
83
69
|
if (shouldIgnoreKey(nodeType)) continue;
|
84
70
|
const fns = visitor[nodeType];
|
85
|
-
let aliases = t
|
86
|
-
const deprecratedKey = t
|
71
|
+
let aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
|
72
|
+
const deprecratedKey = t.DEPRECATED_KEYS[nodeType];
|
87
73
|
|
88
74
|
if (deprecratedKey) {
|
89
75
|
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`);
|
@@ -99,7 +85,7 @@ function explode(visitor) {
|
|
99
85
|
if (existing) {
|
100
86
|
mergePair(existing, fns);
|
101
87
|
} else {
|
102
|
-
visitor[alias] = (0, _clone
|
88
|
+
visitor[alias] = (0, _clone.default)(fns);
|
103
89
|
}
|
104
90
|
}
|
105
91
|
}
|
@@ -126,7 +112,7 @@ function verify(visitor) {
|
|
126
112
|
|
127
113
|
if (shouldIgnoreKey(nodeType)) continue;
|
128
114
|
|
129
|
-
if (t
|
115
|
+
if (t.TYPES.indexOf(nodeType) < 0) {
|
130
116
|
throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
|
131
117
|
}
|
132
118
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babel/traverse",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.6.3",
|
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/",
|
@@ -11,18 +11,18 @@
|
|
11
11
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
|
12
12
|
"main": "lib/index.js",
|
13
13
|
"dependencies": {
|
14
|
-
"@babel/code-frame": "^7.
|
15
|
-
"@babel/generator": "^7.
|
14
|
+
"@babel/code-frame": "^7.5.5",
|
15
|
+
"@babel/generator": "^7.6.3",
|
16
16
|
"@babel/helper-function-name": "^7.1.0",
|
17
17
|
"@babel/helper-split-export-declaration": "^7.4.4",
|
18
|
-
"@babel/parser": "^7.
|
19
|
-
"@babel/types": "^7.
|
18
|
+
"@babel/parser": "^7.6.3",
|
19
|
+
"@babel/types": "^7.6.3",
|
20
20
|
"debug": "^4.1.0",
|
21
21
|
"globals": "^11.1.0",
|
22
|
-
"lodash": "^4.17.
|
22
|
+
"lodash": "^4.17.13"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
25
|
"@babel/helper-plugin-test-runner": "^7.0.0"
|
26
26
|
},
|
27
|
-
"gitHead": "
|
27
|
+
"gitHead": "d329156ebc17da01382acb83e212cb4328534ebc"
|
28
28
|
}
|