babel-plugin-polyfill-corejs3 0.8.1 → 0.8.2
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.
- package/esm/index.mjs +25 -62
- package/esm/index.mjs.map +1 -1
- package/lib/built-in-definitions.js +13 -13
- package/lib/index.js +6 -59
- package/lib/shipped-proposals.js +1 -3
- package/lib/usage-filters.js +0 -6
- package/lib/utils.js +0 -13
- package/package.json +13 -13
package/esm/index.mjs
CHANGED
|
@@ -5,13 +5,13 @@ import corejsEntries from '../core-js-compat/entries.js';
|
|
|
5
5
|
import defineProvider from '@babel/helper-define-polyfill-provider';
|
|
6
6
|
|
|
7
7
|
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.mjs
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var corejs3ShippedProposalsList = new Set(["esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.array-buffer.detached", "esnext.array-buffer.transfer", "esnext.array-buffer.transfer-to-fixed-length", "esnext.json.is-raw-json", "esnext.json.parse", "esnext.json.raw-json", "esnext.set.difference.v2", "esnext.set.intersection.v2", "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of.v2", "esnext.set.symmetric-difference.v2", "esnext.set.union.v2"]);
|
|
9
10
|
|
|
10
11
|
const polyfillsOrder = {};
|
|
11
12
|
Object.keys(corejs3Polyfills).forEach((name, index) => {
|
|
12
13
|
polyfillsOrder[name] = index;
|
|
13
14
|
});
|
|
14
|
-
|
|
15
15
|
const define = (pure, global, name = global[0], exclude) => {
|
|
16
16
|
return {
|
|
17
17
|
name,
|
|
@@ -20,9 +20,7 @@ const define = (pure, global, name = global[0], exclude) => {
|
|
|
20
20
|
exclude
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
|
|
24
23
|
const typed = name => define(null, [name, ...TypedArrayDependencies]);
|
|
25
|
-
|
|
26
24
|
const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
|
|
27
25
|
const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
|
|
28
26
|
const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
|
|
@@ -38,7 +36,7 @@ const SetDependencies = ["es.set", "esnext.set.add-all", "esnext.set.delete-all"
|
|
|
38
36
|
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", ...CommonIteratorsWithTag];
|
|
39
37
|
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
|
|
40
38
|
const DOMExceptionDependencies = ["web.dom-exception.constructor", "web.dom-exception.stack", "web.dom-exception.to-string-tag", "es.error.to-string"];
|
|
41
|
-
const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.size", ...CommonIteratorsWithTag];
|
|
39
|
+
const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.delete", "web.url-search-params.has", "web.url-search-params.size", ...CommonIteratorsWithTag];
|
|
42
40
|
const AsyncIteratorDependencies = ["esnext.async-iterator.constructor", ...PromiseDependencies];
|
|
43
41
|
const AsyncIteratorProblemMethods = ["esnext.async-iterator.every", "esnext.async-iterator.filter", "esnext.async-iterator.find", "esnext.async-iterator.flat-map", "esnext.async-iterator.for-each", "esnext.async-iterator.map", "esnext.async-iterator.reduce", "esnext.async-iterator.some"];
|
|
44
42
|
const IteratorDependencies = ["esnext.iterator.constructor", "es.object.to-string"];
|
|
@@ -202,6 +200,7 @@ const StaticProperties = {
|
|
|
202
200
|
getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]),
|
|
203
201
|
getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]),
|
|
204
202
|
getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]),
|
|
203
|
+
groupBy: define("object/group-by", ["esnext.object.group-by", "es.object.create"]),
|
|
205
204
|
hasOwn: define("object/has-own", ["es.object.has-own"]),
|
|
206
205
|
is: define("object/is", ["es.object.is"]),
|
|
207
206
|
isExtensible: define("object/is-extensible", ["es.object.is-extensible"]),
|
|
@@ -218,7 +217,8 @@ const StaticProperties = {
|
|
|
218
217
|
allSettled: define(null, ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
|
|
219
218
|
any: define(null, ["es.promise.any", "es.aggregate-error", ...PromiseDependenciesWithIterators]),
|
|
220
219
|
race: define(null, PromiseDependenciesWithIterators),
|
|
221
|
-
try: define(null, ["esnext.promise.try", ...
|
|
220
|
+
try: define(null, ["esnext.promise.try", ...PromiseDependencies]),
|
|
221
|
+
withResolvers: define(null, ["esnext.promise.with-resolvers", ...PromiseDependencies])
|
|
222
222
|
},
|
|
223
223
|
Reflect: {
|
|
224
224
|
apply: define("reflect/apply", ["es.reflect.apply"]),
|
|
@@ -262,13 +262,15 @@ const StaticProperties = {
|
|
|
262
262
|
hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
|
|
263
263
|
isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]),
|
|
264
264
|
isRegistered: define("symbol/is-registered", ["esnext.symbol.is-registered", "es.symbol"]),
|
|
265
|
+
isRegisteredSymbol: define("symbol/is-registered-symbol", ["esnext.symbol.is-registered-symbol", "es.symbol"]),
|
|
265
266
|
isWellKnown: define("symbol/is-well-known", ["esnext.symbol.is-well-known", "es.symbol"]),
|
|
267
|
+
isWellKnownSymbol: define("symbol/is-well-known-symbol", ["esnext.symbol.is-well-known-symbol", "es.symbol"]),
|
|
266
268
|
iterator: define("symbol/iterator", ["es.symbol.iterator", ...CommonIteratorsWithTag]),
|
|
267
269
|
keyFor: define("symbol/key-for", [], "es.symbol"),
|
|
268
270
|
match: define("symbol/match", ["es.symbol.match", "es.string.match"]),
|
|
269
271
|
matcher: define("symbol/matcher", ["esnext.symbol.matcher"]),
|
|
270
272
|
matchAll: define("symbol/match-all", ["es.symbol.match-all", "es.string.match-all"]),
|
|
271
|
-
metadata: define("symbol/metadata", ["esnext.symbol.metadata"]),
|
|
273
|
+
metadata: define("symbol/metadata", ["esnext.symbol.metadata", "esnext.function.metadata"]),
|
|
272
274
|
metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]),
|
|
273
275
|
observable: define("symbol/observable", ["esnext.symbol.observable"]),
|
|
274
276
|
patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]),
|
|
@@ -308,7 +310,8 @@ const StaticProperties = {
|
|
|
308
310
|
};
|
|
309
311
|
const InstanceProperties = {
|
|
310
312
|
asIndexedPairs: define("instance/asIndexedPairs", ["esnext.async-iterator.as-indexed-pairs", ...AsyncIteratorDependencies, "esnext.iterator.as-indexed-pairs", ...IteratorDependencies]),
|
|
311
|
-
at: define("instance/at", [
|
|
313
|
+
at: define("instance/at", [
|
|
314
|
+
// TODO: We should introduce overloaded instance methods definition
|
|
312
315
|
// Before that is implemented, the `esnext.string.at` must be the first
|
|
313
316
|
// In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at`
|
|
314
317
|
// and treats the compat-data of `esnext.string.at` as the compat-data of
|
|
@@ -331,7 +334,8 @@ const InstanceProperties = {
|
|
|
331
334
|
emplace: define("instance/emplace", ["esnext.map.emplace", "esnext.weak-map.emplace"]),
|
|
332
335
|
endsWith: define("instance/ends-with", ["es.string.ends-with"]),
|
|
333
336
|
entries: define("instance/entries", ArrayNatureIteratorsWithTag),
|
|
334
|
-
every: define("instance/every", ["es.array.every", "esnext.async-iterator.every",
|
|
337
|
+
every: define("instance/every", ["es.array.every", "esnext.async-iterator.every",
|
|
338
|
+
// TODO: add async iterator dependencies when we support sub-dependencies
|
|
335
339
|
// esnext.async-iterator.every depends on es.promise
|
|
336
340
|
// but we don't want to pull es.promise when esnext.async-iterator is disabled
|
|
337
341
|
//
|
|
@@ -361,7 +365,7 @@ const InstanceProperties = {
|
|
|
361
365
|
includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
|
|
362
366
|
indexed: define("instance/indexed", ["esnext.async-iterator.indexed", ...AsyncIteratorDependencies, "esnext.iterator.indexed", ...IteratorDependencies]),
|
|
363
367
|
indexOf: define("instance/index-of", ["es.array.index-of"]),
|
|
364
|
-
isWellFormed: define("instance/is-well-formed", ["
|
|
368
|
+
isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]),
|
|
365
369
|
italic: define(null, ["es.string.italics"]),
|
|
366
370
|
join: define(null, ["es.array.join"]),
|
|
367
371
|
keys: define("instance/keys", ArrayNatureIteratorsWithTag),
|
|
@@ -410,7 +414,7 @@ const InstanceProperties = {
|
|
|
410
414
|
toSorted: define("instance/to-sorted", ["es.array.to-sorted", "es.array.sort"]),
|
|
411
415
|
toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]),
|
|
412
416
|
toString: define(null, ["es.object.to-string", "es.error.to-string", "es.date.to-string", "es.regexp.to-string"]),
|
|
413
|
-
toWellFormed: define("instance/to-well-formed", ["
|
|
417
|
+
toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]),
|
|
414
418
|
trim: define("instance/trim", ["es.string.trim"]),
|
|
415
419
|
trimEnd: define("instance/trim-end", ["es.string.trim-end"]),
|
|
416
420
|
trimLeft: define("instance/trim-left", ["es.string.trim-start"]),
|
|
@@ -436,7 +440,6 @@ function canSkipPolyfill(desc, path) {
|
|
|
436
440
|
node,
|
|
437
441
|
parent
|
|
438
442
|
} = path;
|
|
439
|
-
|
|
440
443
|
switch (desc.name) {
|
|
441
444
|
case "es.string.split":
|
|
442
445
|
{
|
|
@@ -459,7 +462,6 @@ function callMethod(path, id) {
|
|
|
459
462
|
object
|
|
460
463
|
} = path.node;
|
|
461
464
|
let context1, context2;
|
|
462
|
-
|
|
463
465
|
if (t$1.isIdentifier(object)) {
|
|
464
466
|
context1 = object;
|
|
465
467
|
context2 = t$1.cloneNode(object);
|
|
@@ -467,7 +469,6 @@ function callMethod(path, id) {
|
|
|
467
469
|
context1 = path.scope.generateDeclaredUidIdentifier("context");
|
|
468
470
|
context2 = t$1.assignmentExpression("=", t$1.cloneNode(context1), object);
|
|
469
471
|
}
|
|
470
|
-
|
|
471
472
|
path.replaceWith(t$1.memberExpression(t$1.callExpression(id, [context2]), t$1.identifier("call")));
|
|
472
473
|
path.parentPath.unshiftContainer("arguments", context1);
|
|
473
474
|
}
|
|
@@ -475,7 +476,6 @@ function isCoreJSSource(source) {
|
|
|
475
476
|
if (typeof source === "string") {
|
|
476
477
|
source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
|
|
477
478
|
}
|
|
478
|
-
|
|
479
479
|
return Object.prototype.hasOwnProperty.call(corejsEntries, source) && corejsEntries[source];
|
|
480
480
|
}
|
|
481
481
|
function coreJSModule(name) {
|
|
@@ -491,7 +491,6 @@ const {
|
|
|
491
491
|
const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility";
|
|
492
492
|
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
|
|
493
493
|
const uniqueObjects = ["array", "string", "iterator", "async-iterator", "dom-collections"].map(v => new RegExp(`[a-z]*\\.${v}\\..*`));
|
|
494
|
-
|
|
495
494
|
const esnextFallback = (name, cb) => {
|
|
496
495
|
if (cb(name)) return true;
|
|
497
496
|
if (!name.startsWith("es.")) return false;
|
|
@@ -499,7 +498,6 @@ const esnextFallback = (name, cb) => {
|
|
|
499
498
|
if (!corejs3Polyfills[fallback]) return false;
|
|
500
499
|
return cb(fallback);
|
|
501
500
|
};
|
|
502
|
-
|
|
503
501
|
var index = defineProvider(function ({
|
|
504
502
|
getUtils,
|
|
505
503
|
method,
|
|
@@ -526,21 +524,17 @@ var index = defineProvider(function ({
|
|
|
526
524
|
instance: InstanceProperties
|
|
527
525
|
});
|
|
528
526
|
const available = new Set(getModulesListForTargetVersion(version));
|
|
529
|
-
|
|
530
527
|
function getCoreJSPureBase(useProposalBase) {
|
|
531
528
|
return useBabelRuntime ? useProposalBase ? `${BABEL_RUNTIME}/core-js` : `${BABEL_RUNTIME}/core-js-stable` : useProposalBase ? "core-js-pure/features" : "core-js-pure/stable";
|
|
532
529
|
}
|
|
533
|
-
|
|
534
530
|
function maybeInjectGlobalImpl(name, utils) {
|
|
535
531
|
if (shouldInjectPolyfill(name)) {
|
|
536
532
|
debug(name);
|
|
537
533
|
utils.injectGlobalImport(coreJSModule(name));
|
|
538
534
|
return true;
|
|
539
535
|
}
|
|
540
|
-
|
|
541
536
|
return false;
|
|
542
537
|
}
|
|
543
|
-
|
|
544
538
|
function maybeInjectGlobal(names, utils, fallback = true) {
|
|
545
539
|
for (const name of names) {
|
|
546
540
|
if (fallback) {
|
|
@@ -550,93 +544,75 @@ var index = defineProvider(function ({
|
|
|
550
544
|
}
|
|
551
545
|
}
|
|
552
546
|
}
|
|
553
|
-
|
|
554
547
|
function maybeInjectPure(desc, hint, utils, object) {
|
|
555
548
|
if (desc.pure && !(object && desc.exclude && desc.exclude.includes(object)) && esnextFallback(desc.name, shouldInjectPolyfill)) {
|
|
556
549
|
const {
|
|
557
550
|
name
|
|
558
551
|
} = desc;
|
|
559
552
|
let useProposalBase = false;
|
|
560
|
-
|
|
561
553
|
if (proposals || shippedProposals && name.startsWith("esnext.")) {
|
|
562
554
|
useProposalBase = true;
|
|
563
555
|
} else if (name.startsWith("es.") && !available.has(name)) {
|
|
564
556
|
useProposalBase = true;
|
|
565
557
|
}
|
|
566
|
-
|
|
567
558
|
const coreJSPureBase = getCoreJSPureBase(useProposalBase);
|
|
568
559
|
return utils.injectDefaultImport(`${coreJSPureBase}/${desc.pure}${ext}`, hint);
|
|
569
560
|
}
|
|
570
561
|
}
|
|
571
|
-
|
|
572
562
|
function isFeatureStable(name) {
|
|
573
563
|
if (name.startsWith("esnext.")) {
|
|
574
|
-
const esName = `es.${name.slice(7)}`;
|
|
564
|
+
const esName = `es.${name.slice(7)}`;
|
|
565
|
+
// If its imaginative esName is not in latest compat data, it means
|
|
575
566
|
// the proposal is not stage 4
|
|
576
|
-
|
|
577
567
|
return esName in corejs3Polyfills;
|
|
578
568
|
}
|
|
579
|
-
|
|
580
569
|
return true;
|
|
581
570
|
}
|
|
582
|
-
|
|
583
571
|
return {
|
|
584
572
|
name: "corejs3",
|
|
585
573
|
runtimeName: noRuntimeName ? null : BABEL_RUNTIME,
|
|
586
574
|
polyfills: corejs3Polyfills,
|
|
587
|
-
|
|
588
575
|
filterPolyfills(name) {
|
|
589
576
|
if (!available.has(name)) return false;
|
|
590
577
|
if (proposals || method === "entry-global") return true;
|
|
591
|
-
|
|
592
578
|
if (shippedProposals && corejs3ShippedProposalsList.has(name)) {
|
|
593
579
|
return true;
|
|
594
580
|
}
|
|
595
|
-
|
|
596
581
|
return isFeatureStable(name);
|
|
597
582
|
},
|
|
598
|
-
|
|
599
583
|
entryGlobal(meta, utils, path) {
|
|
600
584
|
if (meta.kind !== "import") return;
|
|
601
585
|
const modules = isCoreJSSource(meta.source);
|
|
602
586
|
if (!modules) return;
|
|
603
|
-
|
|
604
587
|
if (modules.length === 1 && meta.source === coreJSModule(modules[0]) && shouldInjectPolyfill(modules[0])) {
|
|
605
588
|
// Avoid infinite loop: do not replace imports with a new copy of
|
|
606
589
|
// themselves.
|
|
607
590
|
debug(null);
|
|
608
591
|
return;
|
|
609
592
|
}
|
|
610
|
-
|
|
611
593
|
const modulesSet = new Set(modules);
|
|
612
594
|
const filteredModules = modules.filter(module => {
|
|
613
595
|
if (!module.startsWith("esnext.")) return true;
|
|
614
596
|
const stable = module.replace("esnext.", "es.");
|
|
615
|
-
|
|
616
597
|
if (modulesSet.has(stable) && shouldInjectPolyfill(stable)) {
|
|
617
598
|
return false;
|
|
618
599
|
}
|
|
619
|
-
|
|
620
600
|
return true;
|
|
621
601
|
});
|
|
622
602
|
maybeInjectGlobal(filteredModules, utils, false);
|
|
623
603
|
path.remove();
|
|
624
604
|
},
|
|
625
|
-
|
|
626
605
|
usageGlobal(meta, utils, path) {
|
|
627
606
|
const resolved = resolve(meta);
|
|
628
607
|
if (!resolved) return;
|
|
629
608
|
if (canSkipPolyfill(resolved.desc, path)) return;
|
|
630
609
|
let deps = resolved.desc.global;
|
|
631
|
-
|
|
632
610
|
if (resolved.kind !== "global" && "object" in meta && meta.object && meta.placement === "prototype") {
|
|
633
611
|
const low = meta.object.toLowerCase();
|
|
634
612
|
deps = deps.filter(m => uniqueObjects.some(v => v.test(m)) ? m.includes(low) : true);
|
|
635
613
|
}
|
|
636
|
-
|
|
637
614
|
maybeInjectGlobal(deps, utils);
|
|
638
615
|
},
|
|
639
|
-
|
|
640
616
|
usagePure(meta, utils, path) {
|
|
641
617
|
if (meta.kind === "in") {
|
|
642
618
|
if (meta.key === "Symbol.iterator") {
|
|
@@ -646,28 +622,23 @@ var index = defineProvider(function ({
|
|
|
646
622
|
|
|
647
623
|
return;
|
|
648
624
|
}
|
|
649
|
-
|
|
650
625
|
if (path.parentPath.isUnaryExpression({
|
|
651
626
|
operator: "delete"
|
|
652
627
|
})) return;
|
|
653
|
-
|
|
654
628
|
if (meta.kind === "property") {
|
|
655
629
|
// We can't compile destructuring and updateExpression.
|
|
656
630
|
if (!path.isMemberExpression()) return;
|
|
657
631
|
if (!path.isReferenced()) return;
|
|
658
632
|
if (path.parentPath.isUpdateExpression()) return;
|
|
659
|
-
|
|
660
633
|
if (t.isSuper(path.node.object)) {
|
|
661
634
|
return;
|
|
662
635
|
}
|
|
663
|
-
|
|
664
636
|
if (meta.key === "Symbol.iterator") {
|
|
665
637
|
if (!shouldInjectPolyfill("es.symbol.iterator")) return;
|
|
666
638
|
const {
|
|
667
639
|
parent,
|
|
668
640
|
node
|
|
669
641
|
} = path;
|
|
670
|
-
|
|
671
642
|
if (t.isCallExpression(parent, {
|
|
672
643
|
callee: node
|
|
673
644
|
})) {
|
|
@@ -680,39 +651,38 @@ var index = defineProvider(function ({
|
|
|
680
651
|
} else {
|
|
681
652
|
path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"), [path.node.object]));
|
|
682
653
|
}
|
|
683
|
-
|
|
684
654
|
return;
|
|
685
655
|
}
|
|
686
656
|
}
|
|
687
|
-
|
|
688
657
|
let resolved = resolve(meta);
|
|
689
658
|
if (!resolved) return;
|
|
690
659
|
if (canSkipPolyfill(resolved.desc, path)) return;
|
|
691
|
-
|
|
692
660
|
if (useBabelRuntime && resolved.desc.pure && resolved.desc.pure.slice(-6) === "/index") {
|
|
693
661
|
// Remove /index, since it doesn't exist in @babel/runtime-corejs3s
|
|
694
|
-
resolved = {
|
|
695
|
-
|
|
662
|
+
resolved = {
|
|
663
|
+
...resolved,
|
|
664
|
+
desc: {
|
|
665
|
+
...resolved.desc,
|
|
696
666
|
pure: resolved.desc.pure.slice(0, -6)
|
|
697
667
|
}
|
|
698
668
|
};
|
|
699
669
|
}
|
|
700
|
-
|
|
701
670
|
if (resolved.kind === "global") {
|
|
702
671
|
const id = maybeInjectPure(resolved.desc, resolved.name, utils);
|
|
703
672
|
if (id) path.replaceWith(id);
|
|
704
673
|
} else if (resolved.kind === "static") {
|
|
705
|
-
const id = maybeInjectPure(resolved.desc, resolved.name, utils,
|
|
674
|
+
const id = maybeInjectPure(resolved.desc, resolved.name, utils,
|
|
675
|
+
// @ts-expect-error
|
|
706
676
|
meta.object);
|
|
707
677
|
if (id) path.replaceWith(id);
|
|
708
678
|
} else if (resolved.kind === "instance") {
|
|
709
|
-
const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
|
|
679
|
+
const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
|
|
680
|
+
// @ts-expect-error
|
|
710
681
|
meta.object);
|
|
711
682
|
if (!id) return;
|
|
712
683
|
const {
|
|
713
684
|
node
|
|
714
685
|
} = path;
|
|
715
|
-
|
|
716
686
|
if (t.isCallExpression(path.parent, {
|
|
717
687
|
callee: node
|
|
718
688
|
})) {
|
|
@@ -722,13 +692,11 @@ var index = defineProvider(function ({
|
|
|
722
692
|
}
|
|
723
693
|
}
|
|
724
694
|
},
|
|
725
|
-
|
|
726
695
|
visitor: method === "usage-global" && {
|
|
727
696
|
// import("foo")
|
|
728
697
|
CallExpression(path) {
|
|
729
698
|
if (path.get("callee").isImport()) {
|
|
730
699
|
const utils = getUtils(path);
|
|
731
|
-
|
|
732
700
|
if (isWebpack) {
|
|
733
701
|
// Webpack uses Promise.all to handle dynamic import.
|
|
734
702
|
maybeInjectGlobal(PromiseDependenciesWithIterators, utils);
|
|
@@ -737,33 +705,28 @@ var index = defineProvider(function ({
|
|
|
737
705
|
}
|
|
738
706
|
}
|
|
739
707
|
},
|
|
740
|
-
|
|
741
708
|
// (async function () { }).finally(...)
|
|
742
709
|
Function(path) {
|
|
743
710
|
if (path.node.async) {
|
|
744
711
|
maybeInjectGlobal(PromiseDependencies, getUtils(path));
|
|
745
712
|
}
|
|
746
713
|
},
|
|
747
|
-
|
|
748
714
|
// for-of, [a, b] = c
|
|
749
715
|
"ForOfStatement|ArrayPattern"(path) {
|
|
750
716
|
maybeInjectGlobal(CommonIterators, getUtils(path));
|
|
751
717
|
},
|
|
752
|
-
|
|
753
718
|
// [...spread]
|
|
754
719
|
SpreadElement(path) {
|
|
755
720
|
if (!path.parentPath.isObjectExpression()) {
|
|
756
721
|
maybeInjectGlobal(CommonIterators, getUtils(path));
|
|
757
722
|
}
|
|
758
723
|
},
|
|
759
|
-
|
|
760
724
|
// yield*
|
|
761
725
|
YieldExpression(path) {
|
|
762
726
|
if (path.node.delegate) {
|
|
763
727
|
maybeInjectGlobal(CommonIterators, getUtils(path));
|
|
764
728
|
}
|
|
765
729
|
}
|
|
766
|
-
|
|
767
730
|
}
|
|
768
731
|
};
|
|
769
732
|
});
|