This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2014-2020 Denis Pushkarev
Copyright (c) 2014-2022 Denis Pushkarev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+82 -36
View File
@@ -1,53 +1,97 @@
![logo](https://user-images.githubusercontent.com/2213682/146607186-8e13ddef-26a4-4ebf-befd-5aac9d77c090.png)
[`core-js-compat` package](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) contains data about the necessity of [`core-js`](https://github.com/zloirock/core-js) modules and API for getting a list of required core-js modules by browserslist query.
```js
import compat from 'core-js-compat';
const {
list, // array of required modules
targets, // object with targets for each module
} = require('core-js-compat')({
targets: '> 2.5%', // browserslist query or object of minimum environment versions to support
filter: /^(es|web)\./, // optional filter - string-prefix, regexp or list of modules
version: '3.4', // used `core-js` version, by default - the latest
list, // array of required modules
targets, // object with targets for each module
} = compat({
targets: '> 1%', // browserslist query or object of minimum environment versions to support, see below
modules: [ // optional list / filter of modules - regex, sting or an array of them:
'core-js/actual', // - an entry point
'esnext.array.unique-by', // - a module name (or just a start of a module name)
/^web\./, // - regex that a module name must satisfy
],
exclude: [ // optional list / filter of modules to exclude, the signature is similar to `modules` option
'web.atob',
],
version: '3.23', // used `core-js` version, by default - the latest
});
console.log(targets);
/* =>
{
'es.symbol.match-all': { ios: '12.2-12.4' },
'es.array.unscopables.flat': { ios: '12.2-12.4' },
'es.array.unscopables.flat-map': { ios: '12.2-12.4' },
'es.math.hypot': { chrome: '77' },
'es.promise.all-settled': { firefox: '69', ios: '12.2-12.4' },
'es.promise.finally': { ios: '12.2-12.4' },
'es.string.match-all': { chrome: '77', firefox: '69', ios: '12.2-12.4' },
'es.string.replace': { firefox: '69', ios: '12.2-12.4' },
'es.typed-array.float32-array': { ios: '12.2-12.4' },
'es.typed-array.float64-array': { ios: '12.2-12.4' },
'es.typed-array.int8-array': { ios: '12.2-12.4' },
'es.typed-array.int16-array': { ios: '12.2-12.4' },
'es.typed-array.int32-array': { ios: '12.2-12.4' },
'es.typed-array.uint8-array': { ios: '12.2-12.4' },
'es.typed-array.uint8-clamped-array': { ios: '12.2-12.4' },
'es.typed-array.uint16-array': { ios: '12.2-12.4' },
'es.typed-array.uint32-array': { ios: '12.2-12.4' },
'es.typed-array.from': { ios: '12.2-12.4' },
'es.typed-array.of': { ios: '12.2-12.4' },
'web.dom-collections.iterator': { ios: '12.2-12.4' },
'web.immediate': { chrome: '77', firefox: '69', ios: '12.2-12.4' },
'web.url': { ios: '12.2-12.4' },
'web.url.to-json': { ios: '12.2-12.4' },
'web.url-search-params': { ios: '12.2-12.4' }
'es.error.cause': { ios: '14.5-14.8' },
'es.aggregate-error.cause': { ios: '14.5-14.8' },
'es.array.at': { ios: '14.5-14.8' },
'es.array.find-last': { firefox: '100', ios: '14.5-14.8' },
'es.array.find-last-index': { firefox: '100', ios: '14.5-14.8' },
'es.array.includes': { firefox: '100' },
'es.array.push': { chrome: '100', edge: '101', ios: '14.5-14.8', safari: '15.4' },
'es.array.unshift': { ios: '14.5-14.8', safari: '15.4' },
'es.object.has-own': { ios: '14.5-14.8' },
'es.regexp.flags': { chrome: '100', edge: '101' },
'es.string.at-alternative': { ios: '14.5-14.8' },
'es.typed-array.at': { ios: '14.5-14.8' },
'es.typed-array.find-last': { firefox: '100', ios: '14.5-14.8' },
'es.typed-array.find-last-index': { firefox: '100', ios: '14.5-14.8' },
'esnext.array.group': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.group-by': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.group-by-to-map': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.group-to-map': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.to-reversed': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.to-sorted': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.to-spliced': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.unique-by': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.array.with': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.typed-array.to-reversed': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.typed-array.to-sorted': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.typed-array.to-spliced': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'esnext.typed-array.with': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'web.dom-exception.stack': { chrome: '100', edge: '101', ios: '14.5-14.8', safari: '15.4' },
'web.immediate': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' },
'web.structured-clone': { chrome: '100', edge: '101', firefox: '100', ios: '14.5-14.8', safari: '15.4' }
}
*/
```
Additional API:
### `targets` option
`targets` could be [a `browserslist` query](https://github.com/browserslist/browserslist) or a targets object that specifies minimum environment versions to support:
```js
// browserslist query:
'defaults, not IE 11, maintained node versions'
// object:
{
android: '4.0', // Android WebView version
chrome: '38', // Chrome version
deno: '1.12', // Deno version
edge: '13', // Edge version
electron: '5.0', // Electron framework version
firefox: '15', // Firefox version
ie: '8', // Internet Explorer version
ios: '13.0', // iOS Safari version
node: 'current', // NodeJS version, you could use 'current' for set it to currently used
opera: '12', // Opera version
opera_mobile: '7', // Opera Mobile version
phantom: '1.9', // PhantomJS headless browser version
rhino: '1.7.13', // Rhino engine version
safari: '14.0', // Safari version
samsung: '14.0', // Samsung Internet version
esmodules: true, // That option set target to minimum supporting ES Modules versions of all browsers
browsers: '> 0.25%', // Browserslist query or object with target browsers
}
```
### Additional API:
```js
// equals of of the method from the example above
require('core-js-compat/compat')({ targets, filter, version }); // => { list: Array<ModuleName>, targets: { [ModuleName]: { [EngineName]: EngineVersion } } }
require('core-js-compat/compat')({ targets, modules, version }); // => { list: Array<ModuleName>, targets: { [ModuleName]: { [EngineName]: EngineVersion } } }
// or
require('core-js-compat').compat({ targets, filter, version }); // => { list: Array<ModuleName>, targets: { [ModuleName]: { [EngineName]: EngineVersion } } }
require('core-js-compat').compat({ targets, modules, version }); // => { list: Array<ModuleName>, targets: { [ModuleName]: { [EngineName]: EngineVersion } } }
// full compat data:
require('core-js-compat/data'); // => { [ModuleName]: { [EngineName]: EngineVersion } }
@@ -65,9 +109,11 @@ require('core-js-compat/modules'); // => Array<ModuleName>
require('core-js-compat').modules; // => Array<ModuleName>
// the subset of modules which available in the passed `core-js` version:
require('core-js-compat/get-modules-list-for-target-version')('3.3'); // => Array<ModuleName>
require('core-js-compat/get-modules-list-for-target-version')('3.23'); // => Array<ModuleName>
// or
require('core-js-compat').getModulesListForTargetVersion('3.3'); // => Array<ModuleName>
require('core-js-compat').getModulesListForTargetVersion('3.23'); // => Array<ModuleName>
```
If you want to add new / update data about modules required for target engines, [follow this instruction](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md#updating-core-js-compat-data).
If you wanna help to improve this data, you could take a look at the related section of [`CONTRIBUTING.md`](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md#how-to-update-core-js-compat-data). The visualization of compatibility data and the browser tests runner is available [here](http://es6.zloirock.ru/compat/), the example:
![compat-table](https://user-images.githubusercontent.com/2213682/173199354-1f3aeb83-7231-46b2-8a14-a9d47ce3ae45.png)
+40 -18
View File
@@ -1,19 +1,34 @@
'use strict';
const { compare, has, intersection } = require('./helpers');
const { compare, filterOutStabilizedProposals, has, intersection } = require('./helpers');
const data = require('./data');
const entries = require('./entries');
const getModulesListForTargetVersion = require('./get-modules-list-for-target-version');
const modules = require('./modules');
const allModules = require('./modules');
const targetsParser = require('./targets-parser');
function checkModule(name, targets) {
if (!has(data, name)) throw new TypeError(`Incorrect module: ${ name }`);
function getModules(filter) {
if (typeof filter == 'string') {
if (has(entries, filter)) return entries[filter];
return allModules.filter(it => it.startsWith(filter));
} else if (filter instanceof RegExp) return allModules.filter(it => filter.test(it));
throw TypeError('Wrong filter!');
}
const requirements = data[name];
function normalizeModules(option) {
// TODO: use `.flatMap` in core-js@4
return new Set(Array.isArray(option) ? [].concat.apply([], option.map(getModules)) : getModules(option));
}
function checkModule(name, targets) {
const result = {
required: false,
required: !targets,
targets: {},
};
if (!targets) return result;
const requirements = data[name];
for (const [engine, version] of targets) {
if (!has(requirements, engine) || compare(version, '<', requirements[engine])) {
result.required = true;
@@ -24,28 +39,35 @@ function checkModule(name, targets) {
return result;
}
module.exports = function ({ targets, filter, version }) {
const parsedTargets = targetsParser(targets);
module.exports = function ({
filter = null, // TODO: Obsolete, remove from `core-js@4`
modules = null,
exclude = [],
targets = null,
version = null,
} = {}) {
if (modules == null) modules = filter;
const parsedTargets = targets ? targetsParser(targets) : null;
const result = {
list: [],
targets: {},
};
let $modules = Array.isArray(filter) ? filter : modules;
exclude = normalizeModules(exclude);
if (filter instanceof RegExp) {
$modules = $modules.filter(it => filter.test(it));
} else if (typeof filter == 'string') {
$modules = $modules.filter(it => it.startsWith(filter));
}
modules = modules ? [...normalizeModules(modules)] : allModules;
if (version) {
$modules = intersection($modules, getModulesListForTargetVersion(version));
}
if (exclude.size) modules = modules.filter(it => !exclude.has(it));
for (const key of $modules) {
modules = intersection(modules, version ? getModulesListForTargetVersion(version) : allModules);
modules = filterOutStabilizedProposals(modules);
for (const key of modules) {
const check = checkModule(key, parsedTargets);
if (check.required) {
result.list.push(key);
result.targets[key] = check.targets;
+1297 -171
View File
File diff suppressed because it is too large Load Diff
+8352 -181
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -1,6 +1,8 @@
{
"modules": {
"android": "61",
"chrome": "61",
"deno": "1.0",
"edge": "16",
"firefox": "60",
"ios": "10.3",
@@ -9,4 +11,4 @@
"safari": "10.1",
"samsung": "8.0"
}
}
}
+13
View File
@@ -8,6 +8,18 @@ function compare(a, operator, b) {
return cmp(semver(a), operator, semver(b));
}
function filterOutStabilizedProposals(modules) {
const modulesSet = new Set(modules);
for (const $module of modulesSet) {
if ($module.startsWith('esnext.') && modulesSet.has($module.replace(/^esnext\./, 'es.'))) {
modulesSet.delete($module);
}
}
return [...modulesSet];
}
function intersection(list, order) {
const set = list instanceof Set ? list : new Set(list);
return order.filter(name => set.has(name));
@@ -22,6 +34,7 @@ function sortObjectByKey(object, fn) {
module.exports = {
compare,
filterOutStabilizedProposals,
has,
intersection,
semver,
+96 -1
View File
@@ -346,5 +346,100 @@
"3.6": [
"es.regexp.sticky",
"es.regexp.test"
],
"3.7": [
"es.aggregate-error",
"es.promise.any",
"es.reflect.to-string-tag",
"es.string.replace-all",
"esnext.map.emplace",
"esnext.weak-map.emplace"
],
"3.8": [
"esnext.array.at",
"esnext.array.filter-out",
"esnext.array.unique-by",
"esnext.bigint.range",
"esnext.number.range",
"esnext.typed-array.at",
"esnext.typed-array.filter-out"
],
"3.9": [
"esnext.array.find-last",
"esnext.array.find-last-index",
"esnext.typed-array.find-last",
"esnext.typed-array.find-last-index",
"esnext.typed-array.unique-by"
],
"3.11": [
"esnext.object.has-own"
],
"3.12": [
"esnext.symbol.matcher",
"esnext.symbol.metadata"
],
"3.15": [
"es.date.get-year",
"es.date.set-year",
"es.date.to-gmt-string",
"es.escape",
"es.regexp.dot-all",
"es.string.substr",
"es.unescape"
],
"3.16": [
"esnext.array.filter-reject",
"esnext.array.group-by",
"esnext.typed-array.filter-reject",
"esnext.typed-array.group-by"
],
"3.17": [
"es.array.at",
"es.object.has-own",
"es.string.at-alternative",
"es.typed-array.at"
],
"3.18": [
"esnext.array.from-async",
"esnext.typed-array.from-async"
],
"3.20": [
"es.error.cause",
"es.error.to-string",
"es.aggregate-error.cause",
"es.number.to-exponential",
"esnext.array.group-by-to-map",
"esnext.array.to-reversed",
"esnext.array.to-sorted",
"esnext.array.to-spliced",
"esnext.array.with",
"esnext.function.is-callable",
"esnext.function.is-constructor",
"esnext.function.un-this",
"esnext.iterator.to-async",
"esnext.string.cooked",
"esnext.typed-array.to-reversed",
"esnext.typed-array.to-sorted",
"esnext.typed-array.to-spliced",
"esnext.typed-array.with",
"web.dom-exception.constructor",
"web.dom-exception.stack",
"web.dom-exception.to-string-tag",
"web.structured-clone"
],
"3.21": [
"web.atob",
"web.btoa"
],
"3.23": [
"es.array.find-last",
"es.array.find-last-index",
"es.array.push",
"es.array.unshift",
"es.typed-array.find-last",
"es.typed-array.find-last-index",
"esnext.array.group",
"esnext.array.group-to-map",
"esnext.symbol.metadata-key"
]
}
}
+72 -1
View File
@@ -14,6 +14,11 @@
"es.symbol.to-primitive",
"es.symbol.to-string-tag",
"es.symbol.unscopables",
"es.error.cause",
"es.error.to-string",
"es.aggregate-error",
"es.aggregate-error.cause",
"es.array.at",
"es.array.concat",
"es.array.copy-within",
"es.array.every",
@@ -21,6 +26,8 @@
"es.array.filter",
"es.array.find",
"es.array.find-index",
"es.array.find-last",
"es.array.find-last-index",
"es.array.flat",
"es.array.flat-map",
"es.array.for-each",
@@ -33,6 +40,7 @@
"es.array.last-index-of",
"es.array.map",
"es.array.of",
"es.array.push",
"es.array.reduce",
"es.array.reduce-right",
"es.array.reverse",
@@ -43,15 +51,20 @@
"es.array.splice",
"es.array.unscopables.flat",
"es.array.unscopables.flat-map",
"es.array.unshift",
"es.array-buffer.constructor",
"es.array-buffer.is-view",
"es.array-buffer.slice",
"es.data-view",
"es.date.get-year",
"es.date.now",
"es.date.set-year",
"es.date.to-gmt-string",
"es.date.to-iso-string",
"es.date.to-json",
"es.date.to-primitive",
"es.date.to-string",
"es.escape",
"es.function.bind",
"es.function.has-instance",
"es.function.name",
@@ -87,6 +100,7 @@
"es.number.min-safe-integer",
"es.number.parse-float",
"es.number.parse-int",
"es.number.to-exponential",
"es.number.to-fixed",
"es.number.to-precision",
"es.object.assign",
@@ -102,6 +116,7 @@
"es.object.get-own-property-descriptors",
"es.object.get-own-property-names",
"es.object.get-prototype-of",
"es.object.has-own",
"es.object.is",
"es.object.is-extensible",
"es.object.is-frozen",
@@ -118,6 +133,7 @@
"es.parse-int",
"es.promise",
"es.promise.all-settled",
"es.promise.any",
"es.promise.finally",
"es.reflect.apply",
"es.reflect.construct",
@@ -132,13 +148,16 @@
"es.reflect.prevent-extensions",
"es.reflect.set",
"es.reflect.set-prototype-of",
"es.reflect.to-string-tag",
"es.regexp.constructor",
"es.regexp.dot-all",
"es.regexp.exec",
"es.regexp.flags",
"es.regexp.sticky",
"es.regexp.test",
"es.regexp.to-string",
"es.set",
"es.string.at-alternative",
"es.string.code-point-at",
"es.string.ends-with",
"es.string.from-code-point",
@@ -151,9 +170,11 @@
"es.string.raw",
"es.string.repeat",
"es.string.replace",
"es.string.replace-all",
"es.string.search",
"es.string.split",
"es.string.starts-with",
"es.string.substr",
"es.string.trim",
"es.string.trim-end",
"es.string.trim-start",
@@ -179,12 +200,15 @@
"es.typed-array.uint8-clamped-array",
"es.typed-array.uint16-array",
"es.typed-array.uint32-array",
"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.from",
"es.typed-array.includes",
@@ -204,12 +228,28 @@
"es.typed-array.subarray",
"es.typed-array.to-locale-string",
"es.typed-array.to-string",
"es.unescape",
"es.weak-map",
"es.weak-set",
"esnext.aggregate-error",
"esnext.array.from-async",
"esnext.array.at",
"esnext.array.filter-out",
"esnext.array.filter-reject",
"esnext.array.find-last",
"esnext.array.find-last-index",
"esnext.array.group",
"esnext.array.group-by",
"esnext.array.group-by-to-map",
"esnext.array.group-to-map",
"esnext.array.is-template-object",
"esnext.array.last-index",
"esnext.array.last-item",
"esnext.array.to-reversed",
"esnext.array.to-sorted",
"esnext.array.to-spliced",
"esnext.array.unique-by",
"esnext.array.with",
"esnext.async-iterator.constructor",
"esnext.async-iterator.as-indexed-pairs",
"esnext.async-iterator.drop",
@@ -224,8 +264,12 @@
"esnext.async-iterator.some",
"esnext.async-iterator.take",
"esnext.async-iterator.to-array",
"esnext.bigint.range",
"esnext.composite-key",
"esnext.composite-symbol",
"esnext.function.is-callable",
"esnext.function.is-constructor",
"esnext.function.un-this",
"esnext.global-this",
"esnext.iterator.constructor",
"esnext.iterator.as-indexed-pairs",
@@ -241,7 +285,9 @@
"esnext.iterator.some",
"esnext.iterator.take",
"esnext.iterator.to-array",
"esnext.iterator.to-async",
"esnext.map.delete-all",
"esnext.map.emplace",
"esnext.map.every",
"esnext.map.filter",
"esnext.map.find",
@@ -274,6 +320,8 @@
"esnext.math.signbit",
"esnext.math.umulh",
"esnext.number.from-string",
"esnext.number.range",
"esnext.object.has-own",
"esnext.object.iterate-entries",
"esnext.object.iterate-keys",
"esnext.object.iterate-values",
@@ -309,28 +357,51 @@
"esnext.set.symmetric-difference",
"esnext.set.union",
"esnext.string.at",
"esnext.string.cooked",
"esnext.string.code-points",
"esnext.string.match-all",
"esnext.string.replace-all",
"esnext.symbol.async-dispose",
"esnext.symbol.dispose",
"esnext.symbol.matcher",
"esnext.symbol.metadata",
"esnext.symbol.metadata-key",
"esnext.symbol.observable",
"esnext.symbol.pattern-match",
"esnext.symbol.replace-all",
"esnext.typed-array.from-async",
"esnext.typed-array.at",
"esnext.typed-array.filter-out",
"esnext.typed-array.filter-reject",
"esnext.typed-array.find-last",
"esnext.typed-array.find-last-index",
"esnext.typed-array.group-by",
"esnext.typed-array.to-reversed",
"esnext.typed-array.to-sorted",
"esnext.typed-array.to-spliced",
"esnext.typed-array.unique-by",
"esnext.typed-array.with",
"esnext.weak-map.delete-all",
"esnext.weak-map.from",
"esnext.weak-map.of",
"esnext.weak-map.emplace",
"esnext.weak-map.upsert",
"esnext.weak-set.add-all",
"esnext.weak-set.delete-all",
"esnext.weak-set.from",
"esnext.weak-set.of",
"web.atob",
"web.btoa",
"web.dom-collections.for-each",
"web.dom-collections.iterator",
"web.dom-exception.constructor",
"web.dom-exception.stack",
"web.dom-exception.to-string-tag",
"web.immediate",
"web.queue-microtask",
"web.structured-clone",
"web.timers",
"web.url",
"web.url.to-json",
"web.url-search-params"
]
]
+18 -20
View File
@@ -1,45 +1,42 @@
{
"_args": [
[
"core-js-compat@3.6.5",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"core-js-compat@3.23.5",
"/home/node/nuxt"
]
],
"_from": "core-js-compat@3.6.5",
"_id": "core-js-compat@3.6.5",
"_from": "core-js-compat@3.23.5",
"_id": "core-js-compat@3.23.5",
"_inBundle": false,
"_integrity": "sha512-7ItTKOhOZbznhXAQ2g/slGg1PJV5zDO/WdkTwi7UEOJmkvsE32PWvx6mKtDjiMpjnR2CNf6BAD6sSxIlv7ptng==",
"_integrity": "sha512-fHYozIFIxd+91IIbXJgWd/igXIc8Mf9is0fusswjnGIWVG96y2cwyUdlCkGOw6rMLHKAxg7xtCIVaHsyOUnJIg==",
"_location": "/core-js-compat",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "core-js-compat@3.6.5",
"raw": "core-js-compat@3.23.5",
"name": "core-js-compat",
"escapedName": "core-js-compat",
"rawSpec": "3.6.5",
"rawSpec": "3.23.5",
"saveSpec": null,
"fetchSpec": "3.6.5"
"fetchSpec": "3.23.5"
},
"_requiredBy": [
"/@babel/preset-env"
"/@babel/preset-env",
"/@nuxt/babel-preset-app",
"/babel-plugin-polyfill-corejs3"
],
"_resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.6.5.tgz",
"_spec": "3.6.5",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.23.5.tgz",
"_spec": "3.23.5",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/zloirock/core-js/issues"
},
"dependencies": {
"browserslist": "^4.8.5",
"browserslist": "^4.21.2",
"semver": "7.0.0"
},
"description": "core-js compat",
"devDependencies": {
"detective": "^5.2.0",
"electron-to-chromium": "^1.3.332",
"glob": "^7.1.6"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
@@ -50,7 +47,8 @@
"name": "core-js-compat",
"repository": {
"type": "git",
"url": "git+https://github.com/zloirock/core-js.git"
"url": "git+https://github.com/zloirock/core-js.git",
"directory": "packages/core-js-compat"
},
"version": "3.6.5"
"version": "3.23.5"
}
+17 -8
View File
@@ -14,6 +14,7 @@ const aliases = new Map([
const validTargets = new Set([
'android',
'chrome',
'deno',
'edge',
'electron',
'firefox',
@@ -23,20 +24,30 @@ const validTargets = new Set([
'opera',
'opera_mobile',
'phantom',
'rhino',
'safari',
'samsung',
]);
module.exports = function (targets) {
if (typeof targets !== 'object' || Array.isArray(targets)) {
targets = { browsers: targets };
}
const toLowerKeys = function (object) {
return Object.entries(object).reduce((accumulator, [key, value]) => {
accumulator[key.toLowerCase()] = value;
return accumulator;
}, {});
};
module.exports = function (targets) {
const { browsers, esmodules, node, ...rest } = (typeof targets != 'object' || Array.isArray(targets))
? { browsers: targets } : toLowerKeys(targets);
const { browsers, esmodules, node, ...rest } = targets;
const list = Object.entries(rest);
if (browsers) {
list.push(...browserslist(browsers).map(it => it.split(' ')));
if (typeof browsers == 'string' || Array.isArray(browsers)) {
list.push(...browserslist(browsers).map(it => it.split(' ')));
} else {
list.push(...Object.entries(browsers));
}
}
if (esmodules) {
list.push(...Object.entries(external.modules));
@@ -51,8 +62,6 @@ module.exports = function (targets) {
}
if (aliases.has(engine)) {
engine = aliases.get(engine);
} else if (engine === 'android' && compare(version, '>', '4.4.4')) {
engine = 'chrome';
}
return [engine, String(version)];
}).filter(([engine]) => {