babel-plugin-polyfill-corejs3 0.10.4 → 0.11.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.
- package/esm/index.mjs +131 -51
- package/esm/index.mjs.map +1 -1
- package/lib/built-in-definitions.js +60 -34
- package/lib/index.js +44 -8
- package/lib/shipped-proposals.js +1 -1
- package/lib/utils.js +28 -8
- package/package.json +6 -6
|
@@ -25,21 +25,22 @@ const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterat
|
|
|
25
25
|
const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
|
|
26
26
|
const ErrorDependencies = ["es.error.cause", "es.error.to-string"];
|
|
27
27
|
const SuppressedErrorDependencies = ["esnext.suppressed-error.constructor", ...ErrorDependencies];
|
|
28
|
-
const
|
|
28
|
+
const ArrayBufferDependencies = ["es.array-buffer.constructor", "es.array-buffer.slice", "es.data-view", "es.array-buffer.detached", "es.array-buffer.transfer", "es.array-buffer.transfer-to-fixed-length", "es.object.to-string"];
|
|
29
|
+
const TypedArrayDependencies = ["es.typed-array.at", "es.typed-array.copy-within", "es.typed-array.every", "es.typed-array.fill", "es.typed-array.filter", "es.typed-array.find", "es.typed-array.find-index", "es.typed-array.find-last", "es.typed-array.find-last-index", "es.typed-array.for-each", "es.typed-array.includes", "es.typed-array.index-of", "es.typed-array.iterator", "es.typed-array.join", "es.typed-array.last-index-of", "es.typed-array.map", "es.typed-array.reduce", "es.typed-array.reduce-right", "es.typed-array.reverse", "es.typed-array.set", "es.typed-array.slice", "es.typed-array.some", "es.typed-array.sort", "es.typed-array.subarray", "es.typed-array.to-locale-string", "es.typed-array.to-reversed", "es.typed-array.to-sorted", "es.typed-array.to-string", "es.typed-array.with", "es.object.to-string", "es.array.iterator", "esnext.typed-array.filter-reject", "esnext.typed-array.group-by", "esnext.typed-array.to-spliced", "esnext.typed-array.unique-by", ...ArrayBufferDependencies];
|
|
29
30
|
const PromiseDependencies = ["es.promise", "es.object.to-string"];
|
|
30
31
|
exports.PromiseDependencies = PromiseDependencies;
|
|
31
32
|
const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
|
|
32
33
|
exports.PromiseDependenciesWithIterators = PromiseDependenciesWithIterators;
|
|
33
34
|
const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
|
|
34
|
-
const MapDependencies = ["es.map", "esnext.map.delete-all", "esnext.map.emplace", "esnext.map.every", "esnext.map.filter", "esnext.map.find", "esnext.map.find-key", "esnext.map.includes", "esnext.map.key-of", "esnext.map.map-keys", "esnext.map.map-values", "esnext.map.merge", "esnext.map.reduce", "esnext.map.some", "esnext.map.update", ...CommonIteratorsWithTag];
|
|
35
|
-
const SetDependencies = ["es.set", "
|
|
36
|
-
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", ...CommonIteratorsWithTag];
|
|
35
|
+
const MapDependencies = ["es.map", "esnext.map.delete-all", "esnext.map.emplace", "esnext.map.every", "esnext.map.filter", "esnext.map.find", "esnext.map.find-key", "esnext.map.get-or-insert", "esnext.map.get-or-insert-computed", "esnext.map.includes", "esnext.map.key-of", "esnext.map.map-keys", "esnext.map.map-values", "esnext.map.merge", "esnext.map.reduce", "esnext.map.some", "esnext.map.update", ...CommonIteratorsWithTag];
|
|
36
|
+
const SetDependencies = ["es.set", "es.set.difference.v2", "es.set.intersection.v2", "es.set.is-disjoint-from.v2", "es.set.is-subset-of.v2", "es.set.is-superset-of.v2", "es.set.symmetric-difference.v2", "es.set.union.v2", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.is-disjoint-from", "esnext.set.is-subset-of", "esnext.set.is-superset-of", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.union", ...CommonIteratorsWithTag];
|
|
37
|
+
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", "esnext.weak-map.get-or-insert", "esnext.weak-map.get-or-insert-computed", ...CommonIteratorsWithTag];
|
|
37
38
|
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
|
|
38
39
|
const DOMExceptionDependencies = ["web.dom-exception.constructor", "web.dom-exception.stack", "web.dom-exception.to-string-tag", "es.error.to-string"];
|
|
39
40
|
const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.delete", "web.url-search-params.has", "web.url-search-params.size", ...CommonIteratorsWithTag];
|
|
40
41
|
const AsyncIteratorDependencies = ["esnext.async-iterator.constructor", ...PromiseDependencies];
|
|
41
42
|
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"];
|
|
42
|
-
const IteratorDependencies = ["
|
|
43
|
+
const IteratorDependencies = ["es.iterator.constructor", "es.object.to-string"];
|
|
43
44
|
const DecoratorMetadataDependencies = ["esnext.symbol.metadata", "esnext.function.metadata"];
|
|
44
45
|
exports.DecoratorMetadataDependencies = DecoratorMetadataDependencies;
|
|
45
46
|
const TypedArrayStaticMethods = base => ({
|
|
@@ -47,12 +48,12 @@ const TypedArrayStaticMethods = base => ({
|
|
|
47
48
|
fromAsync: define(null, ["esnext.typed-array.from-async", base, ...PromiseDependenciesWithIterators, ...TypedArrayDependencies]),
|
|
48
49
|
of: define(null, ["es.typed-array.of", base, ...TypedArrayDependencies])
|
|
49
50
|
});
|
|
50
|
-
const DataViewDependencies = ["es.data-view",
|
|
51
|
+
const DataViewDependencies = ["es.data-view", ...ArrayBufferDependencies];
|
|
51
52
|
const BuiltIns = {
|
|
52
53
|
AsyncDisposableStack: define("async-disposable-stack/index", ["esnext.async-disposable-stack.constructor", "es.object.to-string", "esnext.async-iterator.async-dispose", "esnext.iterator.dispose", ...PromiseDependencies, ...SuppressedErrorDependencies]),
|
|
53
54
|
AsyncIterator: define("async-iterator/index", AsyncIteratorDependencies),
|
|
54
55
|
AggregateError: define("aggregate-error", ["es.aggregate-error", ...ErrorDependencies, ...CommonIteratorsWithTag, "es.aggregate-error.cause"]),
|
|
55
|
-
ArrayBuffer: define(null,
|
|
56
|
+
ArrayBuffer: define(null, ArrayBufferDependencies),
|
|
56
57
|
DataView: define(null, DataViewDependencies),
|
|
57
58
|
Date: define(null, ["es.date.to-string"]),
|
|
58
59
|
DOMException: define("dom-exception/index", DOMExceptionDependencies),
|
|
@@ -65,7 +66,7 @@ const BuiltIns = {
|
|
|
65
66
|
Int16Array: typed("es.typed-array.int16-array"),
|
|
66
67
|
Int32Array: typed("es.typed-array.int32-array"),
|
|
67
68
|
Iterator: define("iterator/index", IteratorDependencies),
|
|
68
|
-
Uint8Array: typed("es.typed-array.uint8-array", "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex"),
|
|
69
|
+
Uint8Array: typed("es.typed-array.uint8-array", "esnext.uint8-array.set-from-base64", "esnext.uint8-array.set-from-hex", "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex"),
|
|
69
70
|
Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
|
|
70
71
|
Uint16Array: typed("es.typed-array.uint16-array"),
|
|
71
72
|
Uint32Array: typed("es.typed-array.uint32-array"),
|
|
@@ -131,8 +132,9 @@ const StaticProperties = {
|
|
|
131
132
|
isConstructor: define("function/is-constructor", ["esnext.function.is-constructor"])
|
|
132
133
|
},
|
|
133
134
|
Iterator: {
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
concat: define("iterator/concat", ["esnext.iterator.concat", ...IteratorDependencies, ...CommonIterators]),
|
|
136
|
+
from: define("iterator/from", ["es.iterator.from", ...IteratorDependencies, ...CommonIterators]),
|
|
137
|
+
range: define("iterator/range", ["esnext.iterator.range", ...IteratorDependencies, "es.object.to-string"])
|
|
136
138
|
},
|
|
137
139
|
JSON: {
|
|
138
140
|
isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]),
|
|
@@ -169,15 +171,16 @@ const StaticProperties = {
|
|
|
169
171
|
sign: define("math/sign", ["es.math.sign"]),
|
|
170
172
|
signbit: define("math/signbit", ["esnext.math.signbit"]),
|
|
171
173
|
sinh: define("math/sinh", ["es.math.sinh"]),
|
|
174
|
+
sumPrecise: define("math/sum-precise", ["esnext.math.sum-precise", "es.array.iterator"]),
|
|
172
175
|
tanh: define("math/tanh", ["es.math.tanh"]),
|
|
173
176
|
trunc: define("math/trunc", ["es.math.trunc"]),
|
|
174
177
|
umulh: define("math/umulh", ["esnext.math.umulh"])
|
|
175
178
|
},
|
|
176
179
|
Map: {
|
|
177
|
-
from: define(
|
|
180
|
+
from: define("map/from", ["esnext.map.from", ...MapDependencies]),
|
|
178
181
|
groupBy: define("map/group-by", ["es.map.group-by", ...MapDependencies]),
|
|
179
182
|
keyBy: define("map/key-by", ["esnext.map.key-by", ...MapDependencies]),
|
|
180
|
-
of: define(
|
|
183
|
+
of: define("map/of", ["esnext.map.of", ...MapDependencies])
|
|
181
184
|
},
|
|
182
185
|
Number: {
|
|
183
186
|
EPSILON: define("number/epsilon", ["es.number.epsilon"]),
|
|
@@ -222,7 +225,7 @@ const StaticProperties = {
|
|
|
222
225
|
allSettled: define("promise/all-settled", ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
|
|
223
226
|
any: define("promise/any", ["es.promise.any", "es.aggregate-error", ...PromiseDependenciesWithIterators]),
|
|
224
227
|
race: define(null, PromiseDependenciesWithIterators),
|
|
225
|
-
try: define("promise/try", ["
|
|
228
|
+
try: define("promise/try", ["es.promise.try", ...PromiseDependencies]),
|
|
226
229
|
withResolvers: define("promise/with-resolvers", ["es.promise.with-resolvers", ...PromiseDependencies])
|
|
227
230
|
},
|
|
228
231
|
Reflect: {
|
|
@@ -253,8 +256,8 @@ const StaticProperties = {
|
|
|
253
256
|
escape: define("regexp/escape", ["esnext.regexp.escape"])
|
|
254
257
|
},
|
|
255
258
|
Set: {
|
|
256
|
-
from: define(
|
|
257
|
-
of: define(
|
|
259
|
+
from: define("set/from", ["esnext.set.from", ...SetDependencies]),
|
|
260
|
+
of: define("set/of", ["esnext.set.of", ...SetDependencies])
|
|
258
261
|
},
|
|
259
262
|
String: {
|
|
260
263
|
cooked: define("string/cooked", ["esnext.string.cooked"]),
|
|
@@ -265,6 +268,7 @@ const StaticProperties = {
|
|
|
265
268
|
Symbol: {
|
|
266
269
|
asyncDispose: define("symbol/async-dispose", ["esnext.symbol.async-dispose", "esnext.async-iterator.async-dispose"]),
|
|
267
270
|
asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]),
|
|
271
|
+
customMatcher: define("symbol/custom-matcher", ["esnext.symbol.custom-matcher"]),
|
|
268
272
|
dispose: define("symbol/dispose", ["esnext.symbol.dispose", "esnext.iterator.dispose"]),
|
|
269
273
|
for: define("symbol/for", [], "es.symbol"),
|
|
270
274
|
hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
|
|
@@ -291,15 +295,16 @@ const StaticProperties = {
|
|
|
291
295
|
unscopables: define("symbol/unscopables", ["es.symbol.unscopables"])
|
|
292
296
|
},
|
|
293
297
|
URL: {
|
|
294
|
-
canParse: define("url/can-parse", ["web.url.can-parse", "web.url"])
|
|
298
|
+
canParse: define("url/can-parse", ["web.url.can-parse", "web.url"]),
|
|
299
|
+
parse: define("url/parse", ["web.url.parse", "web.url"])
|
|
295
300
|
},
|
|
296
301
|
WeakMap: {
|
|
297
|
-
from: define(
|
|
298
|
-
of: define(
|
|
302
|
+
from: define("weak-map/from", ["esnext.weak-map.from", ...WeakMapDependencies]),
|
|
303
|
+
of: define("weak-map/of", ["esnext.weak-map.of", ...WeakMapDependencies])
|
|
299
304
|
},
|
|
300
305
|
WeakSet: {
|
|
301
|
-
from: define(
|
|
302
|
-
of: define(
|
|
306
|
+
from: define("weak-set/from", ["esnext.weak-set.from", ...WeakSetDependencies]),
|
|
307
|
+
of: define("weak-set/of", ["esnext.weak-set.of", ...WeakSetDependencies])
|
|
303
308
|
},
|
|
304
309
|
Int8Array: TypedArrayStaticMethods("es.typed-array.int8-array"),
|
|
305
310
|
Uint8Array: _extends({
|
|
@@ -321,7 +326,7 @@ const StaticProperties = {
|
|
|
321
326
|
};
|
|
322
327
|
exports.StaticProperties = StaticProperties;
|
|
323
328
|
const InstanceProperties = {
|
|
324
|
-
asIndexedPairs: define(
|
|
329
|
+
asIndexedPairs: define(null, ["esnext.async-iterator.as-indexed-pairs", ...AsyncIteratorDependencies, "esnext.iterator.as-indexed-pairs", ...IteratorDependencies]),
|
|
325
330
|
at: define("instance/at", [
|
|
326
331
|
// TODO: We should introduce overloaded instance methods definition
|
|
327
332
|
// Before that is implemented, the `esnext.string.at` must be the first
|
|
@@ -342,29 +347,39 @@ const InstanceProperties = {
|
|
|
342
347
|
demethodize: define("instance/demethodize", ["esnext.function.demethodize"]),
|
|
343
348
|
description: define(null, ["es.symbol", "es.symbol.description"]),
|
|
344
349
|
dotAll: define(null, ["es.regexp.dot-all"]),
|
|
345
|
-
drop: define(null, ["
|
|
346
|
-
emplace: define("instance/emplace", ["esnext.map.emplace", "esnext.weak-map.emplace"]),
|
|
350
|
+
drop: define(null, ["es.iterator.drop", ...IteratorDependencies, "esnext.async-iterator.drop", ...AsyncIteratorDependencies]),
|
|
347
351
|
endsWith: define("instance/ends-with", ["es.string.ends-with"]),
|
|
348
352
|
entries: define("instance/entries", ArrayNatureIteratorsWithTag),
|
|
349
|
-
every: define("instance/every", ["es.array.every", "
|
|
353
|
+
every: define("instance/every", ["es.array.every", "es.iterator.every", ...IteratorDependencies
|
|
350
354
|
// TODO: add async iterator dependencies when we support sub-dependencies
|
|
351
355
|
// esnext.async-iterator.every depends on es.promise
|
|
352
356
|
// but we don't want to pull es.promise when esnext.async-iterator is disabled
|
|
353
357
|
//
|
|
358
|
+
// "esnext.async-iterator.every",
|
|
354
359
|
// ...AsyncIteratorDependencies
|
|
355
|
-
|
|
360
|
+
]),
|
|
361
|
+
|
|
356
362
|
exec: define(null, ["es.regexp.exec"]),
|
|
357
363
|
fill: define("instance/fill", ["es.array.fill"]),
|
|
358
|
-
filter: define("instance/filter", ["es.array.filter", "
|
|
364
|
+
filter: define("instance/filter", ["es.array.filter", "es.iterator.filter", ...IteratorDependencies
|
|
365
|
+
// "esnext.async-iterator.filter",
|
|
366
|
+
]),
|
|
367
|
+
|
|
359
368
|
filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]),
|
|
360
369
|
finally: define(null, ["es.promise.finally", ...PromiseDependencies]),
|
|
361
|
-
find: define("instance/find", ["es.array.find", "
|
|
370
|
+
find: define("instance/find", ["es.array.find", "es.iterator.find", ...IteratorDependencies
|
|
371
|
+
// "esnext.async-iterator.find",
|
|
372
|
+
]),
|
|
373
|
+
|
|
362
374
|
findIndex: define("instance/find-index", ["es.array.find-index"]),
|
|
363
375
|
findLast: define("instance/find-last", ["es.array.find-last"]),
|
|
364
376
|
findLastIndex: define("instance/find-last-index", ["es.array.find-last-index"]),
|
|
365
377
|
fixed: define(null, ["es.string.fixed"]),
|
|
366
378
|
flags: define("instance/flags", ["es.regexp.flags"]),
|
|
367
|
-
flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map", "
|
|
379
|
+
flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map", "es.iterator.flat-map", ...IteratorDependencies
|
|
380
|
+
// "esnext.async-iterator.flat-map",
|
|
381
|
+
]),
|
|
382
|
+
|
|
368
383
|
flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]),
|
|
369
384
|
getFloat16: define(null, ["esnext.data-view.get-float16", ...DataViewDependencies]),
|
|
370
385
|
getUint8Clamped: define(null, ["esnext.data-view.get-uint8-clamped", ...DataViewDependencies]),
|
|
@@ -375,7 +390,9 @@ const InstanceProperties = {
|
|
|
375
390
|
groupToMap: define("instance/group-to-map", ["esnext.array.group-to-map", "es.map", "es.object.to-string"]),
|
|
376
391
|
fontcolor: define(null, ["es.string.fontcolor"]),
|
|
377
392
|
fontsize: define(null, ["es.string.fontsize"]),
|
|
378
|
-
forEach: define("instance/for-each", ["es.array.for-each", "
|
|
393
|
+
forEach: define("instance/for-each", ["es.array.for-each", "es.iterator.for-each", ...IteratorDependencies,
|
|
394
|
+
// "esnext.async-iterator.for-each",
|
|
395
|
+
"web.dom-collections.for-each"]),
|
|
379
396
|
includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
|
|
380
397
|
indexed: define(null, ["esnext.async-iterator.indexed", ...AsyncIteratorDependencies, "esnext.iterator.indexed", ...IteratorDependencies]),
|
|
381
398
|
indexOf: define("instance/index-of", ["es.array.index-of"]),
|
|
@@ -387,14 +404,20 @@ const InstanceProperties = {
|
|
|
387
404
|
lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]),
|
|
388
405
|
lastItem: define(null, ["esnext.array.last-item"]),
|
|
389
406
|
link: define(null, ["es.string.link"]),
|
|
390
|
-
map: define("instance/map", ["es.array.map", "
|
|
407
|
+
map: define("instance/map", ["es.array.map", "es.iterator.map", ...IteratorDependencies
|
|
408
|
+
// "esnext.async-iterator.map",
|
|
409
|
+
]),
|
|
410
|
+
|
|
391
411
|
match: define(null, ["es.string.match", "es.regexp.exec"]),
|
|
392
412
|
matchAll: define("instance/match-all", ["es.string.match-all", "es.regexp.exec"]),
|
|
393
413
|
name: define(null, ["es.function.name"]),
|
|
394
414
|
padEnd: define("instance/pad-end", ["es.string.pad-end"]),
|
|
395
415
|
padStart: define("instance/pad-start", ["es.string.pad-start"]),
|
|
396
416
|
push: define("instance/push", ["es.array.push"]),
|
|
397
|
-
reduce: define("instance/reduce", ["es.array.reduce", "
|
|
417
|
+
reduce: define("instance/reduce", ["es.array.reduce", "es.iterator.reduce", ...IteratorDependencies
|
|
418
|
+
// "esnext.async-iterator.reduce",
|
|
419
|
+
]),
|
|
420
|
+
|
|
398
421
|
reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]),
|
|
399
422
|
repeat: define("instance/repeat", ["es.string.repeat"]),
|
|
400
423
|
replace: define(null, ["es.string.replace", "es.regexp.exec"]),
|
|
@@ -406,7 +429,10 @@ const InstanceProperties = {
|
|
|
406
429
|
setYear: define(null, ["es.date.set-year"]),
|
|
407
430
|
slice: define("instance/slice", ["es.array.slice"]),
|
|
408
431
|
small: define(null, ["es.string.small"]),
|
|
409
|
-
some: define("instance/some", ["es.array.some", "
|
|
432
|
+
some: define("instance/some", ["es.array.some", "es.iterator.some", ...IteratorDependencies
|
|
433
|
+
// "esnext.async-iterator.some",
|
|
434
|
+
]),
|
|
435
|
+
|
|
410
436
|
sort: define("instance/sort", ["es.array.sort"]),
|
|
411
437
|
splice: define("instance/splice", ["es.array.splice"]),
|
|
412
438
|
split: define(null, ["es.string.split", "es.regexp.exec"]),
|
|
@@ -416,9 +442,9 @@ const InstanceProperties = {
|
|
|
416
442
|
sub: define(null, ["es.string.sub"]),
|
|
417
443
|
substr: define(null, ["es.string.substr"]),
|
|
418
444
|
sup: define(null, ["es.string.sup"]),
|
|
419
|
-
take: define(null, ["
|
|
445
|
+
take: define(null, ["es.iterator.take", ...IteratorDependencies, "esnext.async-iterator.take", ...AsyncIteratorDependencies]),
|
|
420
446
|
test: define(null, ["es.regexp.test", "es.regexp.exec"]),
|
|
421
|
-
toArray: define(null, ["
|
|
447
|
+
toArray: define(null, ["es.iterator.to-array", ...IteratorDependencies, "esnext.async-iterator.to-array", ...AsyncIteratorDependencies]),
|
|
422
448
|
toAsync: define(null, ["esnext.iterator.to-async", ...IteratorDependencies, ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods]),
|
|
423
449
|
toExponential: define(null, ["es.number.to-exponential"]),
|
|
424
450
|
toFixed: define(null, ["es.number.to-fixed"]),
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
18
|
const {
|
|
19
|
-
types: t
|
|
19
|
+
types: t,
|
|
20
|
+
template: template
|
|
20
21
|
} = _babel.default || _babel;
|
|
21
22
|
const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility";
|
|
22
23
|
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
|
|
@@ -161,7 +162,9 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function ({
|
|
|
161
162
|
})) return;
|
|
162
163
|
if (meta.kind === "property") {
|
|
163
164
|
// We can't compile destructuring and updateExpression.
|
|
164
|
-
if (!path.isMemberExpression())
|
|
165
|
+
if (!path.isMemberExpression() && !path.isOptionalMemberExpression()) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
165
168
|
if (!path.isReferenced()) return;
|
|
166
169
|
if (path.parentPath.isUpdateExpression()) return;
|
|
167
170
|
if (t.isSuper(path.node.object)) {
|
|
@@ -206,19 +209,52 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function ({
|
|
|
206
209
|
const id = maybeInjectPure(resolved.desc, resolved.name, utils,
|
|
207
210
|
// @ts-expect-error
|
|
208
211
|
meta.object);
|
|
209
|
-
if (id)
|
|
212
|
+
if (id) {
|
|
213
|
+
path.replaceWith(id);
|
|
214
|
+
let {
|
|
215
|
+
parentPath
|
|
216
|
+
} = path;
|
|
217
|
+
if (parentPath.isOptionalMemberExpression() || parentPath.isOptionalCallExpression()) {
|
|
218
|
+
do {
|
|
219
|
+
const parentAsNotOptional = parentPath;
|
|
220
|
+
parentAsNotOptional.type = parentAsNotOptional.node.type = parentPath.type === "OptionalMemberExpression" ? "MemberExpression" : "CallExpression";
|
|
221
|
+
delete parentAsNotOptional.node.optional;
|
|
222
|
+
({
|
|
223
|
+
parentPath
|
|
224
|
+
} = parentPath);
|
|
225
|
+
} while ((parentPath.isOptionalMemberExpression() || parentPath.isOptionalCallExpression()) && !parentPath.node.optional);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
210
228
|
} else if (resolved.kind === "instance") {
|
|
211
229
|
const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
|
|
212
230
|
// @ts-expect-error
|
|
213
231
|
meta.object);
|
|
214
232
|
if (!id) return;
|
|
215
233
|
const {
|
|
216
|
-
node
|
|
234
|
+
node,
|
|
235
|
+
parent
|
|
217
236
|
} = path;
|
|
218
|
-
if (t.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
(
|
|
237
|
+
if (t.isOptionalCallExpression(parent) && parent.callee === node) {
|
|
238
|
+
const wasOptional = parent.optional;
|
|
239
|
+
parent.optional = !wasOptional;
|
|
240
|
+
if (!wasOptional) {
|
|
241
|
+
const check = (0, _utils.extractOptionalCheck)(path.scope, node);
|
|
242
|
+
const [thisArg, thisArg2] = (0, _utils.maybeMemoizeContext)(node, path.scope);
|
|
243
|
+
path.replaceWith(check(template.expression.ast`
|
|
244
|
+
Function.call.bind(${id}(${thisArg}), ${thisArg2})
|
|
245
|
+
`));
|
|
246
|
+
} else if (t.isOptionalMemberExpression(node)) {
|
|
247
|
+
const check = (0, _utils.extractOptionalCheck)(path.scope, node);
|
|
248
|
+
(0, _utils.callMethod)(path, id, true, check);
|
|
249
|
+
} else {
|
|
250
|
+
(0, _utils.callMethod)(path, id, true);
|
|
251
|
+
}
|
|
252
|
+
} else if (t.isCallExpression(parent) && parent.callee === node) {
|
|
253
|
+
(0, _utils.callMethod)(path, id, false);
|
|
254
|
+
} else if (t.isOptionalMemberExpression(node)) {
|
|
255
|
+
const check = (0, _utils.extractOptionalCheck)(path.scope, node);
|
|
256
|
+
path.replaceWith(check(t.callExpression(id, [node.object])));
|
|
257
|
+
if (t.isOptionalMemberExpression(parent)) parent.optional = true;
|
|
222
258
|
} else {
|
|
223
259
|
path.replaceWith(t.callExpression(id, [node.object]));
|
|
224
260
|
}
|
package/lib/shipped-proposals.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.mjs
|
|
6
|
-
var _default = new Set(["esnext.suppressed-error.constructor", "esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.
|
|
6
|
+
var _default = new Set(["esnext.suppressed-error.constructor", "esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.data-view.get-float16", "esnext.data-view.set-float16", "esnext.json.is-raw-json", "esnext.json.parse", "esnext.json.raw-json", "esnext.math.f16round", "esnext.regexp.escape", "esnext.symbol.async-dispose", "esnext.symbol.dispose", "esnext.symbol.metadata", "esnext.uint8-array.from-base64", "esnext.uint8-array.from-hex", "esnext.uint8-array.set-from-base64", "esnext.uint8-array.set-from-hex", "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex"]);
|
|
7
7
|
exports.default = _default;
|
package/lib/utils.js
CHANGED
|
@@ -5,7 +5,9 @@ exports.BABEL_RUNTIME = void 0;
|
|
|
5
5
|
exports.callMethod = callMethod;
|
|
6
6
|
exports.coreJSModule = coreJSModule;
|
|
7
7
|
exports.coreJSPureHelper = coreJSPureHelper;
|
|
8
|
+
exports.extractOptionalCheck = extractOptionalCheck;
|
|
8
9
|
exports.isCoreJSSource = isCoreJSSource;
|
|
10
|
+
exports.maybeMemoizeContext = maybeMemoizeContext;
|
|
9
11
|
var _babel = _interopRequireWildcard(require("@babel/core"));
|
|
10
12
|
var _entries = _interopRequireDefault(require("../core-js-compat/entries.js"));
|
|
11
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -16,20 +18,38 @@ const {
|
|
|
16
18
|
} = _babel.default || _babel;
|
|
17
19
|
const BABEL_RUNTIME = "@babel/runtime-corejs3";
|
|
18
20
|
exports.BABEL_RUNTIME = BABEL_RUNTIME;
|
|
19
|
-
function callMethod(path, id) {
|
|
21
|
+
function callMethod(path, id, optionalCall, wrapCallee) {
|
|
22
|
+
const [context1, context2] = maybeMemoizeContext(path.node, path.scope);
|
|
23
|
+
let callee = t.callExpression(id, [context1]);
|
|
24
|
+
if (wrapCallee) callee = wrapCallee(callee);
|
|
25
|
+
const call = t.identifier("call");
|
|
26
|
+
path.replaceWith(optionalCall ? t.optionalMemberExpression(callee, call, false, true) : t.memberExpression(callee, call));
|
|
27
|
+
path.parentPath.unshiftContainer("arguments", context2);
|
|
28
|
+
}
|
|
29
|
+
function maybeMemoizeContext(node, scope) {
|
|
20
30
|
const {
|
|
21
31
|
object
|
|
22
|
-
} =
|
|
32
|
+
} = node;
|
|
23
33
|
let context1, context2;
|
|
24
34
|
if (t.isIdentifier(object)) {
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
context2 = object;
|
|
36
|
+
context1 = t.cloneNode(object);
|
|
27
37
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
context2 = scope.generateDeclaredUidIdentifier("context");
|
|
39
|
+
context1 = t.assignmentExpression("=", t.cloneNode(context2), object);
|
|
40
|
+
}
|
|
41
|
+
return [context1, context2];
|
|
42
|
+
}
|
|
43
|
+
function extractOptionalCheck(scope, node) {
|
|
44
|
+
let optionalNode = node;
|
|
45
|
+
while (!optionalNode.optional && t.isOptionalMemberExpression(optionalNode.object)) {
|
|
46
|
+
optionalNode = optionalNode.object;
|
|
30
47
|
}
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
optionalNode.optional = false;
|
|
49
|
+
const ctx = scope.generateDeclaredUidIdentifier("context");
|
|
50
|
+
const assign = t.assignmentExpression("=", ctx, optionalNode.object);
|
|
51
|
+
optionalNode.object = t.cloneNode(ctx);
|
|
52
|
+
return ifNotNullish => t.conditionalExpression(t.binaryExpression("==", assign, t.nullLiteral()), t.unaryExpression("void", t.numericLiteral(0)), ifNotNullish);
|
|
33
53
|
}
|
|
34
54
|
function isCoreJSSource(source) {
|
|
35
55
|
if (typeof source === "string") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-polyfill-corejs3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A Babel plugin to inject imports to core-js@3 polyfills",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"babel-plugin"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/helper-define-polyfill-provider": "^0.6.
|
|
30
|
-
"core-js-compat": "^3.
|
|
29
|
+
"@babel/helper-define-polyfill-provider": "^0.6.3",
|
|
30
|
+
"core-js-compat": "^3.39.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/core": "^7.22.6",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
|
|
40
40
|
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
41
41
|
"@babel/plugin-transform-spread": "^7.22.5",
|
|
42
|
-
"core-js": "^3.
|
|
43
|
-
"core-js-pure": "^3.
|
|
42
|
+
"core-js": "^3.39.0",
|
|
43
|
+
"core-js-pure": "^3.39.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "66340fb145086a826c496f008f67488367846c09"
|
|
49
49
|
}
|