mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-09 14:24:06 +07:00
Improve code quality and write tests
This commit is contained in:
175
node_modules/@babel/preset-env/lib/polyfills/corejs2/built-in-definitions.js
generated
vendored
Normal file
175
node_modules/@babel/preset-env/lib/polyfills/corejs2/built-in-definitions.js
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = void 0;
|
||||
const ArrayNatureIterators = ["es6.object.to-string", "es6.array.iterator", "web.dom.iterable"];
|
||||
const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];
|
||||
const PromiseDependencies = ["es6.object.to-string", "es6.promise"];
|
||||
const BuiltIns = {
|
||||
DataView: "es6.typed.data-view",
|
||||
Float32Array: "es6.typed.float32-array",
|
||||
Float64Array: "es6.typed.float64-array",
|
||||
Int8Array: "es6.typed.int8-array",
|
||||
Int16Array: "es6.typed.int16-array",
|
||||
Int32Array: "es6.typed.int32-array",
|
||||
Map: ["es6.map", ...CommonIterators],
|
||||
Number: "es6.number.constructor",
|
||||
Promise: PromiseDependencies,
|
||||
RegExp: ["es6.regexp.constructor"],
|
||||
Set: ["es6.set", ...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", ...CommonIterators],
|
||||
WeakSet: ["es6.weak-set", ...CommonIterators]
|
||||
};
|
||||
exports.BuiltIns = BuiltIns;
|
||||
const InstanceProperties = {
|
||||
__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"],
|
||||
blink: ["es6.string.blink"],
|
||||
bold: ["es6.string.bold"],
|
||||
codePointAt: ["es6.string.code-point-at"],
|
||||
copyWithin: ["es6.array.copy-within"],
|
||||
endsWith: ["es6.string.ends-with"],
|
||||
entries: ArrayNatureIterators,
|
||||
every: ["es6.array.is-array"],
|
||||
fill: ["es6.array.fill"],
|
||||
filter: ["es6.array.filter"],
|
||||
finally: ["es7.promise.finally", ...PromiseDependencies],
|
||||
find: ["es6.array.find"],
|
||||
findIndex: ["es6.array.find-index"],
|
||||
fixed: ["es6.string.fixed"],
|
||||
flags: ["es6.regexp.flags"],
|
||||
flatMap: ["es7.array.flat-map"],
|
||||
fontcolor: ["es6.string.fontcolor"],
|
||||
fontsize: ["es6.string.fontsize"],
|
||||
forEach: ["es6.array.for-each"],
|
||||
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"],
|
||||
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"],
|
||||
trimEnd: ["es7.string.trim-right"],
|
||||
trimLeft: ["es7.string.trim-left"],
|
||||
trimRight: ["es7.string.trim-right"],
|
||||
trimStart: ["es7.string.trim-left"],
|
||||
values: ArrayNatureIterators
|
||||
};
|
||||
exports.InstanceProperties = InstanceProperties;
|
||||
const StaticProperties = {
|
||||
Array: {
|
||||
from: ["es6.array.from", "es6.string.iterator"],
|
||||
isArray: "es6.array.is-array",
|
||||
of: "es6.array.of"
|
||||
},
|
||||
Date: {
|
||||
now: "es6.date.now"
|
||||
},
|
||||
Object: {
|
||||
assign: "es6.object.assign",
|
||||
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.symbol",
|
||||
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"
|
||||
},
|
||||
Math: {
|
||||
acosh: "es6.math.acosh",
|
||||
asinh: "es6.math.asinh",
|
||||
atanh: "es6.math.atanh",
|
||||
cbrt: "es6.math.cbrt",
|
||||
clz32: "es6.math.clz32",
|
||||
cosh: "es6.math.cosh",
|
||||
expm1: "es6.math.expm1",
|
||||
fround: "es6.math.fround",
|
||||
hypot: "es6.math.hypot",
|
||||
imul: "es6.math.imul",
|
||||
log1p: "es6.math.log1p",
|
||||
log10: "es6.math.log10",
|
||||
log2: "es6.math.log2",
|
||||
sign: "es6.math.sign",
|
||||
sinh: "es6.math.sinh",
|
||||
tanh: "es6.math.tanh",
|
||||
trunc: "es6.math.trunc"
|
||||
},
|
||||
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"
|
||||
},
|
||||
Promise: {
|
||||
all: CommonIterators,
|
||||
race: CommonIterators
|
||||
},
|
||||
Reflect: {
|
||||
apply: "es6.reflect.apply",
|
||||
construct: "es6.reflect.construct",
|
||||
defineProperty: "es6.reflect.define-property",
|
||||
deleteProperty: "es6.reflect.delete-property",
|
||||
get: "es6.reflect.get",
|
||||
getOwnPropertyDescriptor: "es6.reflect.get-own-property-descriptor",
|
||||
getPrototypeOf: "es6.reflect.get-prototype-of",
|
||||
has: "es6.reflect.has",
|
||||
isExtensible: "es6.reflect.is-extensible",
|
||||
ownKeys: "es6.reflect.own-keys",
|
||||
preventExtensions: "es6.reflect.prevent-extensions",
|
||||
set: "es6.reflect.set",
|
||||
setPrototypeOf: "es6.reflect.set-prototype-of"
|
||||
}
|
||||
};
|
||||
exports.StaticProperties = StaticProperties;
|
75
node_modules/@babel/preset-env/lib/polyfills/corejs2/entry-plugin.js
generated
vendored
Normal file
75
node_modules/@babel/preset-env/lib/polyfills/corejs2/entry-plugin.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _corejs2BuiltIns = _interopRequireDefault(require("../../../data/corejs2-built-ins.json"));
|
||||
|
||||
var _getPlatformSpecificDefault = _interopRequireDefault(require("./get-platform-specific-default"));
|
||||
|
||||
var _filterItems = _interopRequireDefault(require("../../filter-items"));
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _debug = require("../../debug");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _default(_, {
|
||||
include,
|
||||
exclude,
|
||||
polyfillTargets,
|
||||
regenerator,
|
||||
debug
|
||||
}) {
|
||||
const polyfills = (0, _filterItems.default)(_corejs2BuiltIns.default, include, exclude, polyfillTargets, (0, _getPlatformSpecificDefault.default)(polyfillTargets));
|
||||
const isPolyfillImport = {
|
||||
ImportDeclaration(path) {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
|
||||
this.replaceBySeparateModulesImport(path);
|
||||
}
|
||||
},
|
||||
|
||||
Program(path) {
|
||||
path.get("body").forEach(bodyPath => {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
|
||||
this.replaceBySeparateModulesImport(bodyPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "corejs2-entry",
|
||||
visitor: isPolyfillImport,
|
||||
|
||||
pre() {
|
||||
this.importPolyfillIncluded = false;
|
||||
|
||||
this.replaceBySeparateModulesImport = function (path) {
|
||||
this.importPolyfillIncluded = true;
|
||||
|
||||
if (regenerator) {
|
||||
(0, _utils.createImport)(path, "regenerator-runtime");
|
||||
}
|
||||
|
||||
const modules = Array.from(polyfills).reverse();
|
||||
|
||||
for (const module of modules) {
|
||||
(0, _utils.createImport)(path, module);
|
||||
}
|
||||
|
||||
path.remove();
|
||||
};
|
||||
},
|
||||
|
||||
post() {
|
||||
if (debug) {
|
||||
(0, _debug.logEntryPolyfills)("@babel/polyfill", this.importPolyfillIncluded, polyfills, this.file.opts.filename, polyfillTargets, _corejs2BuiltIns.default);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
16
node_modules/@babel/preset-env/lib/polyfills/corejs2/get-platform-specific-default.js
generated
vendored
Normal file
16
node_modules/@babel/preset-env/lib/polyfills/corejs2/get-platform-specific-default.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
exports.defaultWebIncludes = void 0;
|
||||
const defaultWebIncludes = ["web.timers", "web.immediate", "web.dom.iterable"];
|
||||
exports.defaultWebIncludes = defaultWebIncludes;
|
||||
|
||||
function _default(targets) {
|
||||
const targetNames = Object.keys(targets);
|
||||
const isAnyTarget = !targetNames.length;
|
||||
const isWebTarget = targetNames.some(name => name !== "node");
|
||||
return isAnyTarget || isWebTarget ? defaultWebIncludes : null;
|
||||
}
|
219
node_modules/@babel/preset-env/lib/polyfills/corejs2/usage-plugin.js
generated
vendored
Normal file
219
node_modules/@babel/preset-env/lib/polyfills/corejs2/usage-plugin.js
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _corejs2BuiltIns = _interopRequireDefault(require("../../../data/corejs2-built-ins.json"));
|
||||
|
||||
var _getPlatformSpecificDefault = _interopRequireDefault(require("./get-platform-specific-default"));
|
||||
|
||||
var _filterItems = _interopRequireDefault(require("../../filter-items"));
|
||||
|
||||
var _builtInDefinitions = require("./built-in-definitions");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _debug = require("../../debug");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const NO_DIRECT_POLYFILL_IMPORT = `
|
||||
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
|
||||
Please remove the \`import '@babel/polyfill'\` call or use \`useBuiltIns: 'entry'\` instead.`;
|
||||
|
||||
function _default({
|
||||
types: t
|
||||
}, {
|
||||
include,
|
||||
exclude,
|
||||
polyfillTargets,
|
||||
debug
|
||||
}) {
|
||||
const polyfills = (0, _filterItems.default)(_corejs2BuiltIns.default, include, exclude, polyfillTargets, (0, _getPlatformSpecificDefault.default)(polyfillTargets));
|
||||
const addAndRemovePolyfillImports = {
|
||||
ImportDeclaration(path) {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
|
||||
console.warn(NO_DIRECT_POLYFILL_IMPORT);
|
||||
path.remove();
|
||||
}
|
||||
},
|
||||
|
||||
Program(path) {
|
||||
path.get("body").forEach(bodyPath => {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
|
||||
console.warn(NO_DIRECT_POLYFILL_IMPORT);
|
||||
bodyPath.remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
ReferencedIdentifier({
|
||||
node: {
|
||||
name
|
||||
},
|
||||
parent,
|
||||
scope
|
||||
}) {
|
||||
if (t.isMemberExpression(parent)) return;
|
||||
if (!(0, _utils.has)(_builtInDefinitions.BuiltIns, name)) return;
|
||||
if (scope.getBindingIdentifier(name)) return;
|
||||
const BuiltInDependencies = _builtInDefinitions.BuiltIns[name];
|
||||
this.addUnsupported(BuiltInDependencies);
|
||||
},
|
||||
|
||||
CallExpression(path) {
|
||||
if (path.node.arguments.length) return;
|
||||
const callee = path.node.callee;
|
||||
if (!t.isMemberExpression(callee)) return;
|
||||
if (!callee.computed) return;
|
||||
|
||||
if (!path.get("callee.property").matchesPattern("Symbol.iterator")) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.addImport("web.dom.iterable");
|
||||
},
|
||||
|
||||
BinaryExpression(path) {
|
||||
if (path.node.operator !== "in") return;
|
||||
if (!path.get("left").matchesPattern("Symbol.iterator")) return;
|
||||
this.addImport("web.dom.iterable");
|
||||
},
|
||||
|
||||
YieldExpression(path) {
|
||||
if (path.node.delegate) {
|
||||
this.addImport("web.dom.iterable");
|
||||
}
|
||||
},
|
||||
|
||||
MemberExpression: {
|
||||
enter(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
const {
|
||||
object,
|
||||
property
|
||||
} = node;
|
||||
if ((0, _utils.isNamespaced)(path.get("object"))) return;
|
||||
let evaluatedPropType = object.name;
|
||||
let propertyName = "";
|
||||
let instanceType = "";
|
||||
|
||||
if (node.computed) {
|
||||
if (t.isStringLiteral(property)) {
|
||||
propertyName = property.value;
|
||||
} else {
|
||||
const result = path.get("property").evaluate();
|
||||
|
||||
if (result.confident && result.value) {
|
||||
propertyName = result.value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
propertyName = property.name;
|
||||
}
|
||||
|
||||
if (path.scope.getBindingIdentifier(object.name)) {
|
||||
const result = path.get("object").evaluate();
|
||||
|
||||
if (result.value) {
|
||||
instanceType = (0, _utils.getType)(result.value);
|
||||
} else if (result.deopt && result.deopt.isIdentifier()) {
|
||||
evaluatedPropType = result.deopt.node.name;
|
||||
}
|
||||
}
|
||||
|
||||
if ((0, _utils.has)(_builtInDefinitions.StaticProperties, evaluatedPropType)) {
|
||||
const BuiltInProperties = _builtInDefinitions.StaticProperties[evaluatedPropType];
|
||||
|
||||
if ((0, _utils.has)(BuiltInProperties, propertyName)) {
|
||||
const StaticPropertyDependencies = BuiltInProperties[propertyName];
|
||||
this.addUnsupported(StaticPropertyDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
if ((0, _utils.has)(_builtInDefinitions.InstanceProperties, propertyName)) {
|
||||
let InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[propertyName];
|
||||
|
||||
if (instanceType) {
|
||||
InstancePropertyDependencies = InstancePropertyDependencies.filter(module => module.includes(instanceType));
|
||||
}
|
||||
|
||||
this.addUnsupported(InstancePropertyDependencies);
|
||||
}
|
||||
},
|
||||
|
||||
exit(path) {
|
||||
const {
|
||||
name
|
||||
} = path.node.object;
|
||||
if (!(0, _utils.has)(_builtInDefinitions.BuiltIns, name)) return;
|
||||
if (path.scope.getBindingIdentifier(name)) return;
|
||||
const BuiltInDependencies = _builtInDefinitions.BuiltIns[name];
|
||||
this.addUnsupported(BuiltInDependencies);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
VariableDeclarator(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
const {
|
||||
id,
|
||||
init
|
||||
} = node;
|
||||
if (!t.isObjectPattern(id)) return;
|
||||
if (init && path.scope.getBindingIdentifier(init.name)) return;
|
||||
|
||||
for (const _ref of id.properties) {
|
||||
const {
|
||||
key
|
||||
} = _ref;
|
||||
|
||||
if (!node.computed && t.isIdentifier(key) && (0, _utils.has)(_builtInDefinitions.InstanceProperties, key.name)) {
|
||||
const InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[key.name];
|
||||
this.addUnsupported(InstancePropertyDependencies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "corejs2-usage",
|
||||
|
||||
pre({
|
||||
path
|
||||
}) {
|
||||
this.polyfillsSet = new Set();
|
||||
|
||||
this.addImport = function (builtIn) {
|
||||
if (!this.polyfillsSet.has(builtIn)) {
|
||||
this.polyfillsSet.add(builtIn);
|
||||
(0, _utils.createImport)(path, builtIn);
|
||||
}
|
||||
};
|
||||
|
||||
this.addUnsupported = function (builtIn) {
|
||||
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
|
||||
|
||||
for (const module of modules) {
|
||||
if (polyfills.has(module)) {
|
||||
this.addImport(module);
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
post() {
|
||||
if (debug) {
|
||||
(0, _debug.logUsagePolyfills)(this.polyfillsSet, this.file.opts.filename, polyfillTargets, _corejs2BuiltIns.default);
|
||||
}
|
||||
},
|
||||
|
||||
visitor: addAndRemovePolyfillImports
|
||||
};
|
||||
}
|
304
node_modules/@babel/preset-env/lib/polyfills/corejs3/built-in-definitions.js
generated
vendored
Normal file
304
node_modules/@babel/preset-env/lib/polyfills/corejs3/built-in-definitions.js
generated
vendored
Normal file
@ -0,0 +1,304 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PossibleGlobalObjects = exports.CommonInstanceDependencies = exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = exports.PromiseDependencies = exports.CommonIterators = void 0;
|
||||
const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
|
||||
const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
|
||||
exports.CommonIterators = CommonIterators;
|
||||
const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
|
||||
const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
|
||||
const TypedArrayDependencies = ["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.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-string", "es.object.to-string", "es.array.iterator", "es.array-buffer.slice"];
|
||||
const TypedArrayStaticMethods = {
|
||||
from: "es.typed-array.from",
|
||||
of: "es.typed-array.of"
|
||||
};
|
||||
const PromiseDependencies = ["es.promise", "es.object.to-string"];
|
||||
exports.PromiseDependencies = PromiseDependencies;
|
||||
const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
|
||||
const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
|
||||
const MapDependencies = ["es.map", "esnext.map.delete-all", "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];
|
||||
const SetDependencies = ["es.set", "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];
|
||||
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", ...CommonIteratorsWithTag];
|
||||
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
|
||||
const URLSearchParamsDependencies = ["web.url", ...CommonIteratorsWithTag];
|
||||
const BuiltIns = {
|
||||
AggregateError: ["esnext.aggregate-error", ...CommonIterators],
|
||||
ArrayBuffer: ["es.array-buffer.constructor", "es.array-buffer.slice", "es.object.to-string"],
|
||||
DataView: ["es.data-view", "es.array-buffer.slice", "es.object.to-string"],
|
||||
Date: ["es.date.to-string"],
|
||||
Float32Array: ["es.typed-array.float32-array", ...TypedArrayDependencies],
|
||||
Float64Array: ["es.typed-array.float64-array", ...TypedArrayDependencies],
|
||||
Int8Array: ["es.typed-array.int8-array", ...TypedArrayDependencies],
|
||||
Int16Array: ["es.typed-array.int16-array", ...TypedArrayDependencies],
|
||||
Int32Array: ["es.typed-array.int32-array", ...TypedArrayDependencies],
|
||||
Uint8Array: ["es.typed-array.uint8-array", ...TypedArrayDependencies],
|
||||
Uint8ClampedArray: ["es.typed-array.uint8-clamped-array", ...TypedArrayDependencies],
|
||||
Uint16Array: ["es.typed-array.uint16-array", ...TypedArrayDependencies],
|
||||
Uint32Array: ["es.typed-array.uint32-array", ...TypedArrayDependencies],
|
||||
Map: MapDependencies,
|
||||
Number: ["es.number.constructor"],
|
||||
Observable: ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag],
|
||||
Promise: PromiseDependencies,
|
||||
RegExp: ["es.regexp.constructor", "es.regexp.exec", "es.regexp.to-string"],
|
||||
Set: SetDependencies,
|
||||
Symbol: SymbolDependencies,
|
||||
URL: ["web.url", ...URLSearchParamsDependencies],
|
||||
URLSearchParams: URLSearchParamsDependencies,
|
||||
WeakMap: WeakMapDependencies,
|
||||
WeakSet: WeakSetDependencies,
|
||||
clearImmediate: ["web.immediate"],
|
||||
compositeKey: ["esnext.composite-key"],
|
||||
compositeSymbol: ["esnext.composite-symbol", ...SymbolDependencies],
|
||||
fetch: PromiseDependencies,
|
||||
globalThis: ["esnext.global-this"],
|
||||
parseFloat: ["es.parse-float"],
|
||||
parseInt: ["es.parse-int"],
|
||||
queueMicrotask: ["web.queue-microtask"],
|
||||
setTimeout: ["web.timers"],
|
||||
setInterval: ["web.timers"],
|
||||
setImmediate: ["web.immediate"]
|
||||
};
|
||||
exports.BuiltIns = BuiltIns;
|
||||
const InstanceProperties = {
|
||||
at: ["esnext.string.at"],
|
||||
anchor: ["es.string.anchor"],
|
||||
big: ["es.string.big"],
|
||||
bind: ["es.function.bind"],
|
||||
blink: ["es.string.blink"],
|
||||
bold: ["es.string.bold"],
|
||||
codePointAt: ["es.string.code-point-at"],
|
||||
codePoints: ["esnext.string.code-points"],
|
||||
concat: ["es.array.concat"],
|
||||
copyWithin: ["es.array.copy-within"],
|
||||
description: ["es.symbol", "es.symbol.description"],
|
||||
endsWith: ["es.string.ends-with"],
|
||||
entries: ArrayNatureIteratorsWithTag,
|
||||
every: ["es.array.every"],
|
||||
exec: ["es.regexp.exec"],
|
||||
fill: ["es.array.fill"],
|
||||
filter: ["es.array.filter"],
|
||||
finally: ["es.promise.finally", ...PromiseDependencies],
|
||||
find: ["es.array.find"],
|
||||
findIndex: ["es.array.find-index"],
|
||||
fixed: ["es.string.fixed"],
|
||||
flags: ["es.regexp.flags"],
|
||||
flat: ["es.array.flat", "es.array.unscopables.flat"],
|
||||
flatMap: ["es.array.flat-map", "es.array.unscopables.flat-map"],
|
||||
fontcolor: ["es.string.fontcolor"],
|
||||
fontsize: ["es.string.fontsize"],
|
||||
forEach: ["es.array.for-each", "web.dom-collections.for-each"],
|
||||
includes: ["es.array.includes", "es.string.includes"],
|
||||
indexOf: ["es.array.index-of"],
|
||||
italic: ["es.string.italics"],
|
||||
join: ["es.array.join"],
|
||||
keys: ArrayNatureIteratorsWithTag,
|
||||
lastIndex: ["esnext.array.last-index"],
|
||||
lastIndexOf: ["es.array.last-index-of"],
|
||||
lastItem: ["esnext.array.last-item"],
|
||||
link: ["es.string.link"],
|
||||
match: ["es.string.match", "es.regexp.exec"],
|
||||
matchAll: ["esnext.string.match-all"],
|
||||
map: ["es.array.map"],
|
||||
name: ["es.function.name"],
|
||||
padEnd: ["es.string.pad-end"],
|
||||
padStart: ["es.string.pad-start"],
|
||||
reduce: ["es.array.reduce"],
|
||||
reduceRight: ["es.array.reduce-right"],
|
||||
repeat: ["es.string.repeat"],
|
||||
replace: ["es.string.replace", "es.regexp.exec"],
|
||||
replaceAll: ["esnext.string.replace-all"],
|
||||
reverse: ["es.array.reverse"],
|
||||
search: ["es.string.search", "es.regexp.exec"],
|
||||
slice: ["es.array.slice"],
|
||||
small: ["es.string.small"],
|
||||
some: ["es.array.some"],
|
||||
sort: ["es.array.sort"],
|
||||
splice: ["es.array.splice"],
|
||||
split: ["es.string.split", "es.regexp.exec"],
|
||||
startsWith: ["es.string.starts-with"],
|
||||
strike: ["es.string.strike"],
|
||||
sub: ["es.string.sub"],
|
||||
sup: ["es.string.sup"],
|
||||
toFixed: ["es.number.to-fixed"],
|
||||
toISOString: ["es.date.to-iso-string"],
|
||||
toJSON: ["es.date.to-json", "web.url.to-json"],
|
||||
toPrecision: ["es.number.to-precision"],
|
||||
toString: ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"],
|
||||
trim: ["es.string.trim"],
|
||||
trimEnd: ["es.string.trim-end"],
|
||||
trimLeft: ["es.string.trim-start"],
|
||||
trimRight: ["es.string.trim-end"],
|
||||
trimStart: ["es.string.trim-start"],
|
||||
values: ArrayNatureIteratorsWithTag,
|
||||
__defineGetter__: ["es.object.define-getter"],
|
||||
__defineSetter__: ["es.object.define-setter"],
|
||||
__lookupGetter__: ["es.object.lookup-getter"],
|
||||
__lookupSetter__: ["es.object.lookup-setter"]
|
||||
};
|
||||
exports.InstanceProperties = InstanceProperties;
|
||||
const StaticProperties = {
|
||||
Array: {
|
||||
from: ["es.array.from", "es.string.iterator"],
|
||||
isArray: ["es.array.is-array"],
|
||||
of: ["es.array.of"]
|
||||
},
|
||||
Date: {
|
||||
now: "es.date.now"
|
||||
},
|
||||
Object: {
|
||||
assign: "es.object.assign",
|
||||
create: "es.object.create",
|
||||
defineProperty: "es.object.define-property",
|
||||
defineProperties: "es.object.define-properties",
|
||||
entries: "es.object.entries",
|
||||
freeze: "es.object.freeze",
|
||||
fromEntries: ["es.object.from-entries", "es.array.iterator"],
|
||||
getOwnPropertyDescriptor: "es.object.get-own-property-descriptor",
|
||||
getOwnPropertyDescriptors: "es.object.get-own-property-descriptors",
|
||||
getOwnPropertyNames: "es.object.get-own-property-names",
|
||||
getOwnPropertySymbols: "es.symbol",
|
||||
getPrototypeOf: "es.object.get-prototype-of",
|
||||
is: "es.object.is",
|
||||
isExtensible: "es.object.is-extensible",
|
||||
isFrozen: "es.object.is-frozen",
|
||||
isSealed: "es.object.is-sealed",
|
||||
keys: "es.object.keys",
|
||||
preventExtensions: "es.object.prevent-extensions",
|
||||
seal: "es.object.seal",
|
||||
setPrototypeOf: "es.object.set-prototype-of",
|
||||
values: "es.object.values"
|
||||
},
|
||||
Math: {
|
||||
DEG_PER_RAD: "esnext.math.deg-per-rad",
|
||||
RAD_PER_DEG: "esnext.math.rad-per-deg",
|
||||
acosh: "es.math.acosh",
|
||||
asinh: "es.math.asinh",
|
||||
atanh: "es.math.atanh",
|
||||
cbrt: "es.math.cbrt",
|
||||
clamp: "esnext.math.clamp",
|
||||
clz32: "es.math.clz32",
|
||||
cosh: "es.math.cosh",
|
||||
degrees: "esnext.math.degrees",
|
||||
expm1: "es.math.expm1",
|
||||
fround: "es.math.fround",
|
||||
fscale: "esnext.math.fscale",
|
||||
hypot: "es.math.hypot",
|
||||
iaddh: "esnext.math.iaddh",
|
||||
imul: "es.math.imul",
|
||||
imulh: "esnext.math.imulh",
|
||||
isubh: "esnext.math.isubh",
|
||||
log1p: "es.math.log1p",
|
||||
log10: "es.math.log10",
|
||||
log2: "es.math.log2",
|
||||
radians: "esnext.math.radians",
|
||||
scale: "esnext.math.scale",
|
||||
seededPRNG: "esnext.math.seeded-prng",
|
||||
sign: "es.math.sign",
|
||||
signbit: "esnext.math.signbit",
|
||||
sinh: "es.math.sinh",
|
||||
tanh: "es.math.tanh",
|
||||
trunc: "es.math.trunc",
|
||||
umulh: "esnext.math.umulh"
|
||||
},
|
||||
String: {
|
||||
fromCodePoint: "es.string.from-code-point",
|
||||
raw: "es.string.raw"
|
||||
},
|
||||
Number: {
|
||||
EPSILON: "es.number.epsilon",
|
||||
MIN_SAFE_INTEGER: "es.number.min-safe-integer",
|
||||
MAX_SAFE_INTEGER: "es.number.max-safe-integer",
|
||||
fromString: "esnext.number.from-string",
|
||||
isFinite: "es.number.is-finite",
|
||||
isInteger: "es.number.is-integer",
|
||||
isSafeInteger: "es.number.is-safe-integer",
|
||||
isNaN: "es.number.is-nan",
|
||||
parseFloat: "es.number.parse-float",
|
||||
parseInt: "es.number.parse-int"
|
||||
},
|
||||
Map: {
|
||||
from: ["esnext.map.from", ...MapDependencies],
|
||||
groupBy: ["esnext.map.group-by", ...MapDependencies],
|
||||
keyBy: ["esnext.map.key-by", ...MapDependencies],
|
||||
of: ["esnext.map.of", ...MapDependencies]
|
||||
},
|
||||
Set: {
|
||||
from: ["esnext.set.from", ...SetDependencies],
|
||||
of: ["esnext.set.of", ...SetDependencies]
|
||||
},
|
||||
WeakMap: {
|
||||
from: ["esnext.weak-map.from", ...WeakMapDependencies],
|
||||
of: ["esnext.weak-map.of", ...WeakMapDependencies]
|
||||
},
|
||||
WeakSet: {
|
||||
from: ["esnext.weak-set.from", ...WeakSetDependencies],
|
||||
of: ["esnext.weak-set.of", ...WeakSetDependencies]
|
||||
},
|
||||
Promise: {
|
||||
all: PromiseDependenciesWithIterators,
|
||||
allSettled: ["esnext.promise.all-settled", ...PromiseDependenciesWithIterators],
|
||||
any: ["esnext.promise.any", ...PromiseDependenciesWithIterators],
|
||||
race: PromiseDependenciesWithIterators,
|
||||
try: ["esnext.promise.try", ...PromiseDependenciesWithIterators]
|
||||
},
|
||||
Reflect: {
|
||||
apply: "es.reflect.apply",
|
||||
construct: "es.reflect.construct",
|
||||
defineMetadata: "esnext.reflect.define-metadata",
|
||||
defineProperty: "es.reflect.define-property",
|
||||
deleteMetadata: "esnext.reflect.delete-metadata",
|
||||
deleteProperty: "es.reflect.delete-property",
|
||||
get: "es.reflect.get",
|
||||
getMetadata: "esnext.reflect.get-metadata",
|
||||
getMetadataKeys: "esnext.reflect.get-metadata-keys",
|
||||
getOwnMetadata: "esnext.reflect.get-own-metadata",
|
||||
getOwnMetadataKeys: "esnext.reflect.get-own-metadata-keys",
|
||||
getOwnPropertyDescriptor: "es.reflect.get-own-property-descriptor",
|
||||
getPrototypeOf: "es.reflect.get-prototype-of",
|
||||
has: "es.reflect.has",
|
||||
hasMetadata: "esnext.reflect.has-metadata",
|
||||
hasOwnMetadata: "esnext.reflect.has-own-metadata",
|
||||
isExtensible: "es.reflect.is-extensible",
|
||||
metadata: "esnext.reflect.metadata",
|
||||
ownKeys: "es.reflect.own-keys",
|
||||
preventExtensions: "es.reflect.prevent-extensions",
|
||||
set: "es.reflect.set",
|
||||
setPrototypeOf: "es.reflect.set-prototype-of"
|
||||
},
|
||||
Symbol: {
|
||||
asyncIterator: ["es.symbol.async-iterator"],
|
||||
dispose: ["esnext.symbol.dispose"],
|
||||
hasInstance: ["es.symbol.has-instance", "es.function.has-instance"],
|
||||
isConcatSpreadable: ["es.symbol.is-concat-spreadable", "es.array.concat"],
|
||||
iterator: ["es.symbol.iterator", ...CommonIteratorsWithTag],
|
||||
match: ["es.symbol.match", "es.string.match"],
|
||||
observable: ["esnext.symbol.observable"],
|
||||
patternMatch: ["esnext.symbol.pattern-match"],
|
||||
replace: ["es.symbol.replace", "es.string.replace"],
|
||||
search: ["es.symbol.search", "es.string.search"],
|
||||
species: ["es.symbol.species", "es.array.species"],
|
||||
split: ["es.symbol.split", "es.string.split"],
|
||||
toPrimitive: ["es.symbol.to-primitive", "es.date.to-primitive"],
|
||||
toStringTag: ["es.symbol.to-string-tag", "es.object.to-string", "es.math.to-string-tag", "es.json.to-string-tag"],
|
||||
unscopables: ["es.symbol.unscopables"]
|
||||
},
|
||||
ArrayBuffer: {
|
||||
isView: ["es.array-buffer.is-view"]
|
||||
},
|
||||
Int8Array: TypedArrayStaticMethods,
|
||||
Uint8Array: TypedArrayStaticMethods,
|
||||
Uint8ClampedArray: TypedArrayStaticMethods,
|
||||
Int16Array: TypedArrayStaticMethods,
|
||||
Uint16Array: TypedArrayStaticMethods,
|
||||
Int32Array: TypedArrayStaticMethods,
|
||||
Uint32Array: TypedArrayStaticMethods,
|
||||
Float32Array: TypedArrayStaticMethods,
|
||||
Float64Array: TypedArrayStaticMethods
|
||||
};
|
||||
exports.StaticProperties = StaticProperties;
|
||||
const CommonInstanceDependencies = new Set(["es.object.to-string", "es.object.define-getter", "es.object.define-setter", "es.object.lookup-getter", "es.object.lookup-setter", "es.regexp.exec"]);
|
||||
exports.CommonInstanceDependencies = CommonInstanceDependencies;
|
||||
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
|
||||
exports.PossibleGlobalObjects = PossibleGlobalObjects;
|
137
node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
generated
vendored
Normal file
137
node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function _data() {
|
||||
const data = _interopRequireDefault(require("core-js-compat/data"));
|
||||
|
||||
_data = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _entries() {
|
||||
const data = _interopRequireDefault(require("core-js-compat/entries"));
|
||||
|
||||
_entries = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _getModulesListForTargetVersion() {
|
||||
const data = _interopRequireDefault(require("core-js-compat/get-modules-list-for-target-version"));
|
||||
|
||||
_getModulesListForTargetVersion = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _filterItems = _interopRequireDefault(require("../../filter-items"));
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _debug = require("../../debug");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function isBabelPolyfillSource(source) {
|
||||
return source === "@babel/polyfill" || source === "babel-polyfill";
|
||||
}
|
||||
|
||||
function isCoreJSSource(source) {
|
||||
if (typeof source === "string") {
|
||||
source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
|
||||
}
|
||||
|
||||
return (0, _utils.has)(_entries().default, source) && _entries().default[source];
|
||||
}
|
||||
|
||||
const BABEL_POLYFILL_DEPRECATION = `
|
||||
\`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
|
||||
and \`regenerator-runtime/runtime\` separately`;
|
||||
|
||||
function _default(_, {
|
||||
corejs,
|
||||
include,
|
||||
exclude,
|
||||
polyfillTargets,
|
||||
debug
|
||||
}) {
|
||||
const polyfills = (0, _filterItems.default)(_data().default, include, exclude, polyfillTargets, null);
|
||||
const available = new Set((0, _getModulesListForTargetVersion().default)(corejs.version));
|
||||
const isPolyfillImport = {
|
||||
ImportDeclaration(path) {
|
||||
const source = (0, _utils.getImportSource)(path);
|
||||
if (!source) return;
|
||||
|
||||
if (isBabelPolyfillSource(source)) {
|
||||
console.warn(BABEL_POLYFILL_DEPRECATION);
|
||||
} else {
|
||||
const modules = isCoreJSSource(source);
|
||||
|
||||
if (modules) {
|
||||
this.replaceBySeparateModulesImport(path, modules);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Program(path) {
|
||||
path.get("body").forEach(bodyPath => {
|
||||
const source = (0, _utils.getRequireSource)(bodyPath);
|
||||
if (!source) return;
|
||||
|
||||
if (isBabelPolyfillSource(source)) {
|
||||
console.warn(BABEL_POLYFILL_DEPRECATION);
|
||||
} else {
|
||||
const modules = isCoreJSSource(source);
|
||||
|
||||
if (modules) {
|
||||
this.replaceBySeparateModulesImport(bodyPath, modules);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "corejs3-entry",
|
||||
visitor: isPolyfillImport,
|
||||
|
||||
pre() {
|
||||
this.polyfillsSet = new Set();
|
||||
|
||||
this.replaceBySeparateModulesImport = function (path, modules) {
|
||||
for (const module of modules) {
|
||||
this.polyfillsSet.add(module);
|
||||
}
|
||||
|
||||
path.remove();
|
||||
};
|
||||
},
|
||||
|
||||
post({
|
||||
path
|
||||
}) {
|
||||
const filtered = (0, _utils.intersection)(polyfills, this.polyfillsSet, available);
|
||||
const reversed = Array.from(filtered).reverse();
|
||||
|
||||
for (const module of reversed) {
|
||||
(0, _utils.createImport)(path, module);
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
(0, _debug.logEntryPolyfills)("core-js", this.polyfillsSet.size > 0, filtered, this.file.opts.filename, polyfillTargets, _data().default);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
8
node_modules/@babel/preset-env/lib/polyfills/corejs3/shipped-proposals.js
generated
vendored
Normal file
8
node_modules/@babel/preset-env/lib/polyfills/corejs3/shipped-proposals.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _default = ["esnext.global-this", "esnext.string.match-all"];
|
||||
exports.default = _default;
|
288
node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
generated
vendored
Normal file
288
node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
generated
vendored
Normal file
@ -0,0 +1,288 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
function _data() {
|
||||
const data = _interopRequireDefault(require("core-js-compat/data"));
|
||||
|
||||
_data = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _shippedProposals = _interopRequireDefault(require("./shipped-proposals"));
|
||||
|
||||
function _getModulesListForTargetVersion() {
|
||||
const data = _interopRequireDefault(require("core-js-compat/get-modules-list-for-target-version"));
|
||||
|
||||
_getModulesListForTargetVersion = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _filterItems = _interopRequireDefault(require("../../filter-items"));
|
||||
|
||||
var _builtInDefinitions = require("./built-in-definitions");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _debug = require("../../debug");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const NO_DIRECT_POLYFILL_IMPORT = `
|
||||
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
|
||||
Please remove the direct import of \`core-js\` or use \`useBuiltIns: 'entry'\` instead.`;
|
||||
const corejs3PolyfillsWithoutProposals = Object.keys(_data().default).filter(name => !name.startsWith("esnext.")).reduce((memo, key) => {
|
||||
memo[key] = _data().default[key];
|
||||
return memo;
|
||||
}, {});
|
||||
|
||||
const corejs3PolyfillsWithShippedProposals = _shippedProposals.default.reduce((memo, key) => {
|
||||
memo[key] = _data().default[key];
|
||||
return memo;
|
||||
}, Object.assign({}, corejs3PolyfillsWithoutProposals));
|
||||
|
||||
function _default(_, {
|
||||
corejs,
|
||||
include,
|
||||
exclude,
|
||||
polyfillTargets,
|
||||
proposals,
|
||||
shippedProposals,
|
||||
debug
|
||||
}) {
|
||||
const polyfills = (0, _filterItems.default)(proposals ? _data().default : shippedProposals ? corejs3PolyfillsWithShippedProposals : corejs3PolyfillsWithoutProposals, include, exclude, polyfillTargets, null);
|
||||
const available = new Set((0, _getModulesListForTargetVersion().default)(corejs.version));
|
||||
|
||||
function resolveKey(path, computed) {
|
||||
const {
|
||||
node,
|
||||
parent,
|
||||
scope
|
||||
} = path;
|
||||
if (path.isStringLiteral()) return node.value;
|
||||
const {
|
||||
name
|
||||
} = node;
|
||||
const isIdentifier = path.isIdentifier();
|
||||
if (isIdentifier && !(computed || parent.computed)) return name;
|
||||
|
||||
if (!isIdentifier || scope.getBindingIdentifier(name)) {
|
||||
const {
|
||||
value
|
||||
} = path.evaluate();
|
||||
if (typeof value === "string") return value;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveSource(path) {
|
||||
const {
|
||||
node,
|
||||
scope
|
||||
} = path;
|
||||
let builtIn, instanceType;
|
||||
|
||||
if (node) {
|
||||
builtIn = node.name;
|
||||
|
||||
if (!path.isIdentifier() || scope.getBindingIdentifier(builtIn)) {
|
||||
const {
|
||||
deopt,
|
||||
value
|
||||
} = path.evaluate();
|
||||
|
||||
if (value !== undefined) {
|
||||
instanceType = (0, _utils.getType)(value);
|
||||
} else if (deopt && deopt.isIdentifier()) {
|
||||
builtIn = deopt.node.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
builtIn,
|
||||
instanceType,
|
||||
isNamespaced: (0, _utils.isNamespaced)(path)
|
||||
};
|
||||
}
|
||||
|
||||
const addAndRemovePolyfillImports = {
|
||||
ImportDeclaration(path) {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
|
||||
console.warn(NO_DIRECT_POLYFILL_IMPORT);
|
||||
path.remove();
|
||||
}
|
||||
},
|
||||
|
||||
Program(path) {
|
||||
path.get("body").forEach(bodyPath => {
|
||||
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
|
||||
console.warn(NO_DIRECT_POLYFILL_IMPORT);
|
||||
bodyPath.remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Import() {
|
||||
this.addUnsupported(_builtInDefinitions.PromiseDependencies);
|
||||
},
|
||||
|
||||
Function({
|
||||
node
|
||||
}) {
|
||||
if (node.async) {
|
||||
this.addUnsupported(_builtInDefinitions.PromiseDependencies);
|
||||
}
|
||||
},
|
||||
|
||||
"ForOfStatement|ArrayPattern"() {
|
||||
this.addUnsupported(_builtInDefinitions.CommonIterators);
|
||||
},
|
||||
|
||||
SpreadElement({
|
||||
parentPath
|
||||
}) {
|
||||
if (!parentPath.isObjectExpression()) {
|
||||
this.addUnsupported(_builtInDefinitions.CommonIterators);
|
||||
}
|
||||
},
|
||||
|
||||
YieldExpression({
|
||||
node
|
||||
}) {
|
||||
if (node.delegate) {
|
||||
this.addUnsupported(_builtInDefinitions.CommonIterators);
|
||||
}
|
||||
},
|
||||
|
||||
ReferencedIdentifier({
|
||||
node: {
|
||||
name
|
||||
},
|
||||
scope
|
||||
}) {
|
||||
if (scope.getBindingIdentifier(name)) return;
|
||||
this.addBuiltInDependencies(name);
|
||||
},
|
||||
|
||||
MemberExpression(path) {
|
||||
const source = resolveSource(path.get("object"));
|
||||
const key = resolveKey(path.get("property"));
|
||||
this.addPropertyDependencies(source, key);
|
||||
},
|
||||
|
||||
ObjectPattern(path) {
|
||||
const {
|
||||
parentPath,
|
||||
parent,
|
||||
key
|
||||
} = path;
|
||||
let source;
|
||||
|
||||
if (parentPath.isVariableDeclarator()) {
|
||||
source = resolveSource(parentPath.get("init"));
|
||||
} else if (parentPath.isAssignmentExpression()) {
|
||||
source = resolveSource(parentPath.get("right"));
|
||||
} else if (parentPath.isFunctionExpression()) {
|
||||
const grand = parentPath.parentPath;
|
||||
|
||||
if (grand.isCallExpression() || grand.isNewExpression()) {
|
||||
if (grand.node.callee === parent) {
|
||||
source = resolveSource(grand.get("arguments")[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const property of path.get("properties")) {
|
||||
if (property.isObjectProperty()) {
|
||||
const key = resolveKey(property.get("key"));
|
||||
this.addPropertyDependencies(source, key);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
BinaryExpression(path) {
|
||||
if (path.node.operator !== "in") return;
|
||||
const source = resolveSource(path.get("right"));
|
||||
const key = resolveKey(path.get("left"), true);
|
||||
this.addPropertyDependencies(source, key);
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "corejs3-usage",
|
||||
|
||||
pre() {
|
||||
this.polyfillsSet = new Set();
|
||||
|
||||
this.addUnsupported = function (builtIn) {
|
||||
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
|
||||
|
||||
for (const module of modules) {
|
||||
this.polyfillsSet.add(module);
|
||||
}
|
||||
};
|
||||
|
||||
this.addBuiltInDependencies = function (builtIn) {
|
||||
if ((0, _utils.has)(_builtInDefinitions.BuiltIns, builtIn)) {
|
||||
const BuiltInDependencies = _builtInDefinitions.BuiltIns[builtIn];
|
||||
this.addUnsupported(BuiltInDependencies);
|
||||
}
|
||||
};
|
||||
|
||||
this.addPropertyDependencies = function (source = {}, key) {
|
||||
const {
|
||||
builtIn,
|
||||
instanceType,
|
||||
isNamespaced
|
||||
} = source;
|
||||
if (isNamespaced) return;
|
||||
|
||||
if (_builtInDefinitions.PossibleGlobalObjects.has(builtIn)) {
|
||||
this.addBuiltInDependencies(key);
|
||||
} else if ((0, _utils.has)(_builtInDefinitions.StaticProperties, builtIn)) {
|
||||
const BuiltInProperties = _builtInDefinitions.StaticProperties[builtIn];
|
||||
|
||||
if ((0, _utils.has)(BuiltInProperties, key)) {
|
||||
const StaticPropertyDependencies = BuiltInProperties[key];
|
||||
return this.addUnsupported(StaticPropertyDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(0, _utils.has)(_builtInDefinitions.InstanceProperties, key)) return;
|
||||
let InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[key];
|
||||
|
||||
if (instanceType) {
|
||||
InstancePropertyDependencies = InstancePropertyDependencies.filter(m => m.includes(instanceType) || _builtInDefinitions.CommonInstanceDependencies.has(m));
|
||||
}
|
||||
|
||||
this.addUnsupported(InstancePropertyDependencies);
|
||||
};
|
||||
},
|
||||
|
||||
post({
|
||||
path
|
||||
}) {
|
||||
const filtered = (0, _utils.intersection)(polyfills, this.polyfillsSet, available);
|
||||
const reversed = Array.from(filtered).reverse();
|
||||
|
||||
for (const module of reversed) {
|
||||
(0, _utils.createImport)(path, module);
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
(0, _debug.logUsagePolyfills)(filtered, this.file.opts.filename, polyfillTargets, _data().default);
|
||||
}
|
||||
},
|
||||
|
||||
visitor: addAndRemovePolyfillImports
|
||||
};
|
||||
}
|
48
node_modules/@babel/preset-env/lib/polyfills/regenerator/entry-plugin.js
generated
vendored
Normal file
48
node_modules/@babel/preset-env/lib/polyfills/regenerator/entry-plugin.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
function isRegeneratorSource(source) {
|
||||
return source === "regenerator-runtime/runtime";
|
||||
}
|
||||
|
||||
function _default() {
|
||||
const visitor = {
|
||||
ImportDeclaration(path) {
|
||||
if (isRegeneratorSource((0, _utils.getImportSource)(path))) {
|
||||
this.regeneratorImportExcluded = true;
|
||||
path.remove();
|
||||
}
|
||||
},
|
||||
|
||||
Program(path) {
|
||||
path.get("body").forEach(bodyPath => {
|
||||
if (isRegeneratorSource((0, _utils.getRequireSource)(bodyPath))) {
|
||||
this.regeneratorImportExcluded = true;
|
||||
bodyPath.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "regenerator-entry",
|
||||
visitor,
|
||||
|
||||
pre() {
|
||||
this.regeneratorImportExcluded = false;
|
||||
},
|
||||
|
||||
post() {
|
||||
if (this.opts.debug && this.regeneratorImportExcluded) {
|
||||
console.log(`\n[${this.file.opts.filename}] Based on your targets, regenerator-runtime import excluded.`);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
39
node_modules/@babel/preset-env/lib/polyfills/regenerator/usage-plugin.js
generated
vendored
Normal file
39
node_modules/@babel/preset-env/lib/polyfills/regenerator/usage-plugin.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
function _default() {
|
||||
return {
|
||||
name: "regenerator-usage",
|
||||
|
||||
pre() {
|
||||
this.usesRegenerator = false;
|
||||
},
|
||||
|
||||
visitor: {
|
||||
Function(path) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
|
||||
if (!this.usesRegenerator && (node.generator || node.async)) {
|
||||
this.usesRegenerator = true;
|
||||
(0, _utils.createImport)(path, "regenerator-runtime");
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
post() {
|
||||
if (this.opts.debug && this.usesRegenerator) {
|
||||
console.log(`\n[${this.file.opts.filename}] Based on your code and targets, added regenerator-runtime.`);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user