Improve useBuiltIns: usage mappins in preset-env (#7810)

This commit is contained in:
Brian Ng 2018-05-07 11:45:09 -05:00 committed by GitHub
parent 3e9b59c0f1
commit 6dca0ff9bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 105 additions and 45 deletions

View File

@ -1,67 +1,97 @@
const ArrayNatureIterators = [
"es6.object.to-string",
"es6.array.iterator",
"web.dom.iterable",
];
const CommonIterators = ["es6.string.iterator"].concat(ArrayNatureIterators);
// TODO: this is the opposite of built-in-features so maybe generate one from the other?
export const definitions = {
builtins: {
DataView: "es6.typed.data-view",
Int8Array: "es6.typed.int8-array",
Uint8Array: "es6.typed.uint8-array",
Uint8ClampedArray: "es6.typed.uint8-clamped-array",
Int16Array: "es6.typed.int16-array",
Uint16Array: "es6.typed.uint16-array",
Int32Array: "es6.typed.int32-array",
Uint32Array: "es6.typed.uint32-array",
Float32Array: "es6.typed.float32-array",
Float64Array: "es6.typed.float64-array",
Map: "es6.map",
Set: "es6.set",
WeakMap: "es6.weak-map",
WeakSet: "es6.weak-set",
Int8Array: "es6.typed.int8-array",
Int16Array: "es6.typed.int16-array",
Int32Array: "es6.typed.int32-array",
Map: ["es6.map"].concat(CommonIterators),
Number: "es6.number.constructor",
Promise: ["es6.object.to-string", "es6.promise"],
RegExp: ["es6.regexp.constructor"],
Set: ["es6.set"].concat(CommonIterators),
Symbol: ["es6.symbol", "es7.symbol.async-iterator"],
Uint8Array: "es6.typed.uint8-array",
Uint8ClampedArray: "es6.typed.uint8-clamped-array",
Uint16Array: "es6.typed.uint16-array",
Uint32Array: "es6.typed.uint32-array",
WeakMap: ["es6.weak-map"].concat(CommonIterators),
WeakSet: ["es6.weak-set"].concat(CommonIterators),
},
instanceMethods: {
__defineGetter__: ["es7.object.define-getter"],
__defineSetter__: ["es7.object.define-setter"],
__lookupGetter__: ["es7.object.lookup-getter"],
__lookupSetter__: ["es7.object.lookup-setter"],
anchor: ["es6.string.anchor"],
big: ["es6.string.big"],
bind: ["es6.function.bind"],
name: ["es6.function.name"],
blink: ["es6.string.blink"],
bold: ["es6.string.bold"],
codePointAt: ["es6.string.code-point-at"],
endsWith: ["es6.string.ends-with"],
fromCodePoint: ["es6.string.from-code-point"],
includes: ["es6.string.includes", "es7.array.includes"],
repeat: ["es6.string.repeat"],
startsWith: ["es6.string.starts-with"],
trim: ["es6.string.trim"],
flags: ["es6.regexp.flags"],
match: ["es6.regexp.match"],
replace: ["es6.regexp.replace"],
split: ["es6.regexp.split"],
search: ["es6.regexp.search"],
copyWithin: ["es6.array.copy-within"],
endsWith: ["es6.string.ends-with"],
entries: ArrayNatureIterators,
every: ["es6.array.is-array"],
find: ["es6.array.find"],
findIndex: ["es6.array.find-index"],
fill: ["es6.array.fill"],
filter: ["es6.array.filter"],
forEach: ["es6.array.for-each"],
find: ["es6.array.find"],
findIndex: ["es6.array.find-index"],
fixed: ["es6.string.fixed"],
flags: ["es6.regexp.flags"],
fontcolor: ["es6.string.fontcolor"],
fontsize: ["es6.string.fontsize"],
forEach: ["es6.array.for-each", "web.dom.iterable"],
includes: ["es6.string.includes", "es7.array.includes"],
indexOf: ["es6.array.index-of"],
italics: ["es6.string.italics"],
keys: ArrayNatureIterators,
lastIndexOf: ["es6.array.last-index-of"],
link: ["es6.string.link"],
map: ["es6.array.map"],
reduce: ["es6.array.reduce"],
reduceRight: ["es6.array.reduce-right"],
some: ["es6.array.some"],
sort: ["es6.array.sort"],
match: ["es6.regexp.match"],
name: ["es6.function.name"],
padStart: ["es7.string.pad-start"],
padEnd: ["es7.string.pad-end"],
reduce: ["es6.array.reduce"],
reduceRight: ["es6.array.reduce-right"],
repeat: ["es6.string.repeat"],
replace: ["es6.regexp.replace"],
search: ["es6.regexp.search"],
slice: ["es6.array.slice"],
small: ["es6.string.small"],
some: ["es6.array.some"],
sort: ["es6.array.sort"],
split: ["es6.regexp.split"],
startsWith: ["es6.string.starts-with"],
strike: ["es6.string.strike"],
sub: ["es6.string.sub"],
sup: ["es6.string.sup"],
toISOString: ["es6.date.to-iso-string"],
toJSON: ["es6.date.to-json"],
toString: [
"es6.object.to-string",
"es6.date.to-string",
"es6.regexp.to-string",
],
trim: ["es6.string.trim"],
values: ArrayNatureIterators,
},
staticMethods: {
Array: {
from: "es6.array.from",
from: ["es6.array.from", "es6.string.iterator"],
isArray: "es6.array.is-array",
of: "es6.array.of",
},
@ -72,12 +102,22 @@ export const definitions = {
Object: {
assign: "es6.object.assign",
is: "es6.object.is",
create: "es6.object.create",
defineProperty: "es6.object.define-property",
defineProperties: "es6.object.define-properties",
entries: "es7.object.entries",
freeze: "es6.object.freeze",
getOwnPropertyDescriptors: "es7.object.get-own-property-descriptors",
getOwnPropertySymbols: "es6.object.get-own-property-symbols",
is: "es6.object.is",
isExtensible: "es6.object.is-extensible",
isFrozen: "es6.object.is-frozen",
isSealed: "es6.object.is-sealed",
keys: "es6.object.keys",
preventExtensions: "es6.object.prevent-extensions",
seal: "es6.object.seal",
setPrototypeOf: "es6.object.set-prototype-of",
values: "es7.object.values",
entries: "es7.object.entries",
getOwnPropertyDescriptors: "es7.object.get-own-property-descriptors",
},
Math: {
@ -101,24 +141,25 @@ export const definitions = {
},
String: {
fromCodePoint: "es6.string.from-code-point",
raw: "es6.string.raw",
},
Number: {
EPSILON: "es6.number.epsilon",
MIN_SAFE_INTEGER: "es6.number.min-safe-integer",
MAX_SAFE_INTEGER: "es6.number.max-safe-integer",
isFinite: "es6.number.is-finite",
isInteger: "es6.number.is-integer",
isSafeInteger: "es6.number.is-safe-integer",
isNaN: "es6.number.is-nan",
parseFloat: "es6.number.parse-float",
parseInt: "es6.number.parse-int",
EPSILON: "es6.number.epsilon",
MIN_SAFE_INTEGER: "es6.number.min-safe-integer",
MAX_SAFE_INTEGER: "es6.number.max-safe-integer",
},
Promise: {
all: ["es6.string.iterator", "web.dom.iterable"],
race: ["es6.string.iterator", "web.dom.iterable"],
all: CommonIterators,
race: CommonIterators,
},
Reflect: {

View File

@ -41,6 +41,8 @@ Using polyfills with `usage` option:
[src/in.js] Added following polyfills:
es6.promise { "ie":"11" }
es6.map { "firefox":"50", "ie":"11" }
es6.array.iterator { "ie":"11" }
web.dom.iterable { "chrome":"52", "firefox":"50", "ie":"11" }
[src/in2.js] Added following polyfills:
regenerator-runtime { "chrome":"52", "firefox":"50", "ie":"11" }

View File

@ -1,4 +1,6 @@
import "core-js/modules/es6.object.assign";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
var objectClass = Object;
var arrayInstance = [];
var assignStr = "assign";

View File

@ -1,3 +1,4 @@
import "core-js/modules/web.dom.iterable";
Array.from; // static function
Map; // top level built-in

View File

@ -13,7 +13,10 @@ import "core-js/modules/es6.array.find-index";
import "core-js/modules/es6.array.find";
import "core-js/modules/es7.array.includes";
import "core-js/modules/es6.string.includes";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.map";
import "core-js/modules/es6.string.iterator";
import "core-js/modules/es6.array.from";
Array.from; // static function

View File

@ -1,4 +1,5 @@
import "core-js/modules/es7.symbol.async-iterator";
import "core-js/modules/web.dom.iterable";
Array.from; // static method
Map; // built-in

View File

@ -1,9 +1,11 @@
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es7.symbol.async-iterator";
import "core-js/modules/es6.symbol";
import "core-js/modules/es6.regexp.match";
import "core-js/modules/es6.promise";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.map";
import "core-js/modules/es6.string.iterator";
import "core-js/modules/es6.array.from";
Array.from; // static method

View File

@ -1,4 +1,5 @@
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.promise";
var p = Promise.resolve(0);
Promise.all([p]).then(function (outcome) {

View File

@ -1,4 +1,5 @@
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.promise";
var p = Promise.resolve(0);
Promise.race([p]).then(function (outcome) {

View File

@ -6,6 +6,12 @@ require("core-js/modules/es6.array.filter");
require("core-js/modules/es6.array.index-of");
require("core-js/modules/web.dom.iterable");
require("core-js/modules/es6.array.iterator");
require("core-js/modules/es6.object.keys");
require("regenerator-runtime/runtime");
require("core-js/modules/es7.symbol.async-iterator");