Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Aug 26, 2021
1 parent 4fe615d commit 2ec5b26
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
50 changes: 43 additions & 7 deletions packages/babel-plugin-polyfill-corejs3/src/built-in-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ const TypedArrayDependencies = [
"es.object.to-string",
"es.array.iterator",
"es.array-buffer.slice",
"esnext.typed-array.at",
"esnext.typed-array.filter-reject",
"esnext.typed-array.find-last",
"esnext.typed-array.find-last-index",
"esnext.typed-array.group-by",
"esnext.typed-array.unique-by",
];

const TypedArrayStaticMethods = {
Expand All @@ -96,6 +102,7 @@ const SymbolDependencies = [
const MapDependencies = [
"es.map",
"esnext.map.delete-all",
"esnext.map.emplace",
"esnext.map.every",
"esnext.map.filter",
"esnext.map.find",
Expand Down Expand Up @@ -135,6 +142,7 @@ const SetDependencies = [
const WeakMapDependencies = [
"es.weak-map",
"esnext.weak-map.delete-all",
"esnext.weak-map.emplace",
...CommonIteratorsWithTag,
];

Expand All @@ -150,10 +158,18 @@ const URLSearchParamsDependencies = [
...CommonIteratorsWithTag,
];

const AsyncIteratorDependencies = [
"esnext.async-iterator.constructor",
...PromiseDependencies,
];

const IteratorDependencies = [
"esnext.iterator.constructor",
"es.object.to-string",
];

export const BuiltIns: ObjectMap<CoreJSPolyfillDescriptor> = {
AsyncIterator: define("async-iterator/index", [
"esnext.async-iterator.constructor",
]),
AsyncIterator: define("async-iterator/index", AsyncIteratorDependencies),
AggregateError: define("aggregate-error", [
"es.aggregate-error",
...CommonIterators,
Expand All @@ -174,7 +190,7 @@ export const BuiltIns: ObjectMap<CoreJSPolyfillDescriptor> = {
Int8Array: typed("es.typed-array.int8-array"),
Int16Array: typed("es.typed-array.int16-array"),
Int32Array: typed("es.typed-array.int32-array"),
Iterator: define("iterator/index", ["esnext.iterator.constructor"]),
Iterator: define("iterator/index", IteratorDependencies),
Uint8Array: typed("es.typed-array.uint8-array"),
Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
Uint16Array: typed("es.typed-array.uint16-array"),
Expand All @@ -190,7 +206,9 @@ export const BuiltIns: ObjectMap<CoreJSPolyfillDescriptor> = {
Promise: define("promise/index", PromiseDependencies),
RegExp: define(null, [
"es.regexp.constructor",
"es.regexp.dot-all",
"es.regexp.exec",
"es.regexp.sticky",
"es.regexp.to-string",
]),
Set: define("set/index", SetDependencies),
Expand All @@ -217,7 +235,10 @@ export const StaticProperties: ObjectMap<
ObjectMap<CoreJSPolyfillDescriptor>,
> = {
AsyncIterator: {
from: define("async-iterator/from", ["esnext.async-iterator.from"]),
from: define("async-iterator/from", [
"esnext.async-iterator.from",
...AsyncIteratorDependencies,
]),
},
Array: {
from: define("array/from", ["es.array.from", "es.string.iterator"]),
Expand All @@ -241,7 +262,10 @@ export const StaticProperties: ObjectMap<
},

Iterator: {
from: define("iterator/from", ["esnext.iterator.from"]),
from: define("iterator/from", [
"esnext.iterator.from",
...IteratorDependencies,
]),
},

JSON: {
Expand Down Expand Up @@ -360,7 +384,11 @@ export const StaticProperties: ObjectMap<
"es.promise.all-settled",
...PromiseDependenciesWithIterators,
]),
any: define(null, ["es.promise.any", ...PromiseDependenciesWithIterators]),
any: define(null, [
"es.promise.any",
"es.aggregate-error",
...PromiseDependenciesWithIterators,
]),
race: define(null, PromiseDependenciesWithIterators),
try: define(null, [
"esnext.promise.try",
Expand Down Expand Up @@ -517,7 +545,9 @@ export const StaticProperties: ObjectMap<
export const InstanceProperties = {
asIndexedPairs: define("instance/asIndexedPairs", [
"esnext.async-iterator.as-indexed-pairs",
...AsyncIteratorDependencies,
"esnext.iterator.as-indexed-pairs",
...IteratorDependencies,
]),
at: define("instance/at", [
"esnext.string.at",
Expand All @@ -537,7 +567,9 @@ export const InstanceProperties = {
dotAll: define("instance/dot-all", ["es.regexp.dot-all"]),
drop: define("instance/drop", [
"esnext.async-iterator.drop",
...AsyncIteratorDependencies,
"esnext.iterator.drop",
...IteratorDependencies,
]),
emplace: define("instance/emplace", [
"esnext.map.emplace",
Expand Down Expand Up @@ -647,11 +679,15 @@ export const InstanceProperties = {
sup: define(null, ["es.string.sup"]),
take: define("instance/take", [
"esnext.async-iterator.take",
...AsyncIteratorDependencies,
"esnext.iterator.take",
...IteratorDependencies,
]),
toArray: define("instance/to-array", [
"esnext.async-iterator.to-array",
...AsyncIteratorDependencies,
"esnext.iterator.to-array",
...IteratorDependencies,
]),
toFixed: define(null, ["es.number.to-fixed"]),
toISOString: define(null, ["es.date.to-iso-string"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import "core-js/modules/esnext.array.find-last.js";
import "core-js/modules/esnext.typed-array.find-last.js";
import "core-js/modules/esnext.array.find-last-index.js";
import "core-js/modules/esnext.typed-array.find-last-index.js";
import "core-js/modules/esnext.async-iterator.constructor.js";
import "core-js/modules/esnext.async-iterator.to-array.js";
import "core-js/modules/esnext.iterator.constructor.js";
import "core-js/modules/esnext.iterator.to-array.js";
import "core-js/modules/esnext.async-iterator.for-each.js";
import "core-js/modules/esnext.iterator.for-each.js";
import "core-js/modules/esnext.iterator.from.js";
import "core-js/modules/esnext.iterator.constructor.js";
import "core-js/modules/esnext.async-iterator.map.js";
import "core-js/modules/esnext.iterator.map.js";
import "core-js/modules/esnext.array.group-by.js";
Expand All @@ -19,7 +20,6 @@ import "core-js/modules/esnext.iterator.take.js";
import "core-js/modules/esnext.async-iterator.drop.js";
import "core-js/modules/esnext.iterator.drop.js";
import "core-js/modules/esnext.async-iterator.from.js";
import "core-js/modules/esnext.async-iterator.constructor.js";
import "core-js/modules/esnext.array.unique-by.js";
import "core-js/modules/esnext.typed-array.unique-by.js";
import "core-js/modules/esnext.number.range.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import "core-js/modules/es.typed-array.sort.js";
import "core-js/modules/es.typed-array.subarray.js";
import "core-js/modules/es.typed-array.to-locale-string.js";
import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/esnext.typed-array.at.js";
import "core-js/modules/esnext.array.at.js";
import "core-js/modules/esnext.string.at.js";
import "core-js/modules/esnext.typed-array.at.js";
// obscuring instance type
let tmp;

Expand Down

0 comments on commit 2ec5b26

Please sign in to comment.