Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

22
my-app/node_modules/babel-plugin-polyfill-corejs3/LICENSE generated vendored Executable file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Nicolò Ribaudo and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

78
my-app/node_modules/babel-plugin-polyfill-corejs3/README.md generated vendored Executable file
View file

@ -0,0 +1,78 @@
# babel-plugin-polyfill-corejs3
## Install
Using npm:
```sh
npm install --save-dev babel-plugin-polyfill-corejs3
```
or using yarn:
```sh
yarn add babel-plugin-polyfill-corejs3 --dev
```
## Usage
Add this plugin to your Babel configuration:
```json
{
"plugins": [["polyfill-corejs3", { "method": "usage-global", "version": "3.20" }]]
}
```
This package supports the `usage-pure`, `usage-global`, and `entry-global` methods.
When `entry-global` is used, it replaces imports to `core-js`.
## Options
See [here](../../docs/usage.md#options) for a list of options supported by every polyfill provider.
### `version`
`string`, defaults to `"3.0"`.
This option only has an effect when used alongside `"method": "usage-global"` or `"method": "usage-pure"`. It is recommended to specify the minor version you are using as `core-js@3.0` may not include polyfills for the latest features. If you are bundling an app, you can provide the version directly from your node modules:
```js
{
plugins: [
["polyfill-corejs3", {
"method": "usage-pure",
// use `core-js/package.json` if you are using `usage-global`
"version": require("core-js-pure/package.json").version
}]
]
}
```
If you are a library author, specify a reasonably modern `core-js` version in your
`package.json` and provide the plugin the minimal supported version.
```json
{
"dependencies": {
"core-js": "^3.20.0"
}
}
```
```js
{
plugins: [
["polyfill-corejs3", {
"method": "usage-global",
// improvise if you have more complicated version spec, e.g. > 3.1.4
"version": require("./package.json").dependencies["core-js"]
}]
]
}
```
### `proposals`
`boolean`, defaults to `false`.
This option only has an effect when used alongside `"method": "usage-global"` or `"method": "usage-pure"`. When `proposals` are `true`, any ES proposal supported by core-js will be polyfilled as well.

View file

@ -0,0 +1,4 @@
`core-js-compat` exposes some files as JSON, and they cannot be
imported by Node.js ESM files.
This folder proxies `core-js-compat` to ensure that every entry
is CJS and can be safely imported.

View file

@ -0,0 +1 @@
module.exports = require("core-js-compat/data");

View file

@ -0,0 +1 @@
module.exports = require("core-js-compat/entries");

View file

@ -0,0 +1 @@
module.exports = require("core-js-compat/get-modules-list-for-target-version");

View file

@ -0,0 +1,756 @@
import corejs3Polyfills from '../core-js-compat/data.js';
import getModulesListForTargetVersion from '../core-js-compat/get-modules-list-for-target-version.js';
import * as _babel from '@babel/core';
import corejsEntries from '../core-js-compat/entries.js';
import defineProvider from '@babel/helper-define-polyfill-provider';
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.mjs
var corejs3ShippedProposalsList = new Set(["esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.array-buffer.detached", "esnext.array-buffer.transfer", "esnext.array-buffer.transfer-to-fixed-length", "esnext.iterator.constructor", "esnext.iterator.drop", "esnext.iterator.every", "esnext.iterator.filter", "esnext.iterator.find", "esnext.iterator.flat-map", "esnext.iterator.for-each", "esnext.iterator.from", "esnext.iterator.map", "esnext.iterator.reduce", "esnext.iterator.some", "esnext.iterator.take", "esnext.iterator.to-array", "esnext.json.is-raw-json", "esnext.json.parse", "esnext.json.raw-json", "esnext.map.group-by", "esnext.object.group-by", "esnext.promise.with-resolvers", "esnext.set.difference.v2", "esnext.set.intersection.v2", "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of.v2", "esnext.set.symmetric-difference.v2", "esnext.set.union.v2", "esnext.symbol.async-dispose", "esnext.symbol.dispose"]);
const polyfillsOrder = {};
Object.keys(corejs3Polyfills).forEach((name, index) => {
polyfillsOrder[name] = index;
});
const define = (pure, global, name = global[0], exclude) => {
return {
name,
pure,
global: global.sort((a, b) => polyfillsOrder[a] - polyfillsOrder[b]),
exclude
};
};
const typed = name => define(null, [name, ...TypedArrayDependencies]);
const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
const ErrorDependencies = ["es.error.cause", "es.error.to-string"];
const SuppressedErrorDependencies = ["esnext.suppressed-error.constructor", ...ErrorDependencies];
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", "es.array-buffer.slice", "esnext.array-buffer.detached", "esnext.array-buffer.transfer", "esnext.array-buffer.transfer-to-fixed-length", "esnext.typed-array.filter-reject", "esnext.typed-array.group-by", "esnext.typed-array.to-spliced", "esnext.typed-array.unique-by"];
const PromiseDependencies = ["es.promise", "es.object.to-string"];
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.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];
const SetDependencies = ["es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.difference.v2", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.intersection.v2", "esnext.set.is-disjoint-from", "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of", "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of", "esnext.set.is-superset-of.v2", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.symmetric-difference.v2", "esnext.set.union", "esnext.set.union.v2", ...CommonIteratorsWithTag];
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", ...CommonIteratorsWithTag];
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
const DOMExceptionDependencies = ["web.dom-exception.constructor", "web.dom-exception.stack", "web.dom-exception.to-string-tag", "es.error.to-string"];
const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.delete", "web.url-search-params.has", "web.url-search-params.size", ...CommonIteratorsWithTag];
const AsyncIteratorDependencies = ["esnext.async-iterator.constructor", ...PromiseDependencies];
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"];
const IteratorDependencies = ["esnext.iterator.constructor", "es.object.to-string"];
const DecoratorMetadataDependencies = ["esnext.symbol.metadata", "esnext.function.metadata"];
const TypedArrayStaticMethods = {
from: define(null, ["es.typed-array.from"]),
fromAsync: define(null, ["esnext.typed-array.from-async", ...PromiseDependenciesWithIterators]),
of: define(null, ["es.typed-array.of"])
};
const DataViewDependencies = ["es.data-view", "es.array-buffer.slice", "es.object.to-string"];
const BuiltIns = {
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]),
AsyncIterator: define("async-iterator/index", AsyncIteratorDependencies),
AggregateError: define("aggregate-error", ["es.aggregate-error", ...ErrorDependencies, ...CommonIteratorsWithTag, "es.aggregate-error.cause"]),
ArrayBuffer: define(null, ["es.array-buffer.constructor", "es.array-buffer.slice", "es.object.to-string"]),
DataView: define(null, DataViewDependencies),
Date: define(null, ["es.date.to-string"]),
DOMException: define("dom-exception/index", DOMExceptionDependencies),
DisposableStack: define("disposable-stack/index", ["esnext.disposable-stack.constructor", "es.object.to-string", "esnext.iterator.dispose", ...SuppressedErrorDependencies]),
Error: define(null, ErrorDependencies),
EvalError: define(null, ErrorDependencies),
Float32Array: typed("es.typed-array.float32-array"),
Float64Array: typed("es.typed-array.float64-array"),
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", IteratorDependencies),
Uint8Array: typed("es.typed-array.uint8-array"),
Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
Uint16Array: typed("es.typed-array.uint16-array"),
Uint32Array: typed("es.typed-array.uint32-array"),
Map: define("map/index", MapDependencies),
Number: define(null, ["es.number.constructor"]),
Observable: define("observable/index", ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag]),
Promise: define("promise/index", PromiseDependencies),
RangeError: define(null, ErrorDependencies),
ReferenceError: define(null, ErrorDependencies),
Reflect: define(null, ["es.reflect.to-string-tag", "es.object.to-string"]),
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),
SuppressedError: define("suppressed-error", SuppressedErrorDependencies),
Symbol: define("symbol/index", SymbolDependencies),
SyntaxError: define(null, ErrorDependencies),
TypeError: define(null, ErrorDependencies),
URIError: define(null, ErrorDependencies),
URL: define("url/index", ["web.url", ...URLSearchParamsDependencies]),
URLSearchParams: define("url-search-params/index", URLSearchParamsDependencies),
WeakMap: define("weak-map/index", WeakMapDependencies),
WeakSet: define("weak-set/index", WeakSetDependencies),
atob: define("atob", ["web.atob", ...DOMExceptionDependencies]),
btoa: define("btoa", ["web.btoa", ...DOMExceptionDependencies]),
clearImmediate: define("clear-immediate", ["web.immediate"]),
compositeKey: define("composite-key", ["esnext.composite-key"]),
compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]),
escape: define("escape", ["es.escape"]),
fetch: define(null, PromiseDependencies),
globalThis: define("global-this", ["es.global-this"]),
parseFloat: define("parse-float", ["es.parse-float"]),
parseInt: define("parse-int", ["es.parse-int"]),
queueMicrotask: define("queue-microtask", ["web.queue-microtask"]),
self: define("self", ["web.self"]),
setImmediate: define("set-immediate", ["web.immediate"]),
setInterval: define("set-interval", ["web.timers"]),
setTimeout: define("set-timeout", ["web.timers"]),
structuredClone: define("structured-clone", ["web.structured-clone", ...DOMExceptionDependencies, "es.array.iterator", "es.object.keys", "es.object.to-string", "es.map", "es.set"]),
unescape: define("unescape", ["es.unescape"])
};
const StaticProperties = {
AsyncIterator: {
from: define("async-iterator/from", ["esnext.async-iterator.from", ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods, ...CommonIterators])
},
Array: {
from: define("array/from", ["es.array.from", "es.string.iterator"]),
fromAsync: define("array/from-async", ["esnext.array.from-async", ...PromiseDependenciesWithIterators]),
isArray: define("array/is-array", ["es.array.is-array"]),
isTemplateObject: define("array/is-template-object", ["esnext.array.is-template-object"]),
of: define("array/of", ["es.array.of"])
},
ArrayBuffer: {
isView: define(null, ["es.array-buffer.is-view"])
},
BigInt: {
range: define("bigint/range", ["esnext.bigint.range", "es.object.to-string"])
},
Date: {
now: define("date/now", ["es.date.now"])
},
Function: {
isCallable: define("function/is-callable", ["esnext.function.is-callable"]),
isConstructor: define("function/is-constructor", ["esnext.function.is-constructor"])
},
Iterator: {
from: define("iterator/from", ["esnext.iterator.from", ...IteratorDependencies, ...CommonIterators]),
range: define("iterator/range", ["esnext.iterator.range", "es.object.to-string"])
},
JSON: {
isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]),
parse: define("json/parse", ["esnext.json.parse", "es.object.keys"]),
rawJSON: define("json/raw-json", ["esnext.json.raw-json", "es.object.create", "es.object.freeze"]),
stringify: define("json/stringify", ["es.json.stringify"], "es.symbol")
},
Math: {
DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]),
RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]),
acosh: define("math/acosh", ["es.math.acosh"]),
asinh: define("math/asinh", ["es.math.asinh"]),
atanh: define("math/atanh", ["es.math.atanh"]),
cbrt: define("math/cbrt", ["es.math.cbrt"]),
clamp: define("math/clamp", ["esnext.math.clamp"]),
clz32: define("math/clz32", ["es.math.clz32"]),
cosh: define("math/cosh", ["es.math.cosh"]),
degrees: define("math/degrees", ["esnext.math.degrees"]),
expm1: define("math/expm1", ["es.math.expm1"]),
fround: define("math/fround", ["es.math.fround"]),
f16round: define("math/f16round", ["esnext.math.f16round"]),
fscale: define("math/fscale", ["esnext.math.fscale"]),
hypot: define("math/hypot", ["es.math.hypot"]),
iaddh: define("math/iaddh", ["esnext.math.iaddh"]),
imul: define("math/imul", ["es.math.imul"]),
imulh: define("math/imulh", ["esnext.math.imulh"]),
isubh: define("math/isubh", ["esnext.math.isubh"]),
log10: define("math/log10", ["es.math.log10"]),
log1p: define("math/log1p", ["es.math.log1p"]),
log2: define("math/log2", ["es.math.log2"]),
radians: define("math/radians", ["esnext.math.radians"]),
scale: define("math/scale", ["esnext.math.scale"]),
seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]),
sign: define("math/sign", ["es.math.sign"]),
signbit: define("math/signbit", ["esnext.math.signbit"]),
sinh: define("math/sinh", ["es.math.sinh"]),
tanh: define("math/tanh", ["es.math.tanh"]),
trunc: define("math/trunc", ["es.math.trunc"]),
umulh: define("math/umulh", ["esnext.math.umulh"])
},
Map: {
from: define(null, ["esnext.map.from", ...MapDependencies]),
groupBy: define(null, ["esnext.map.group-by", ...MapDependencies]),
keyBy: define(null, ["esnext.map.key-by", ...MapDependencies]),
of: define(null, ["esnext.map.of", ...MapDependencies])
},
Number: {
EPSILON: define("number/epsilon", ["es.number.epsilon"]),
MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]),
MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]),
fromString: define("number/from-string", ["esnext.number.from-string"]),
isFinite: define("number/is-finite", ["es.number.is-finite"]),
isInteger: define("number/is-integer", ["es.number.is-integer"]),
isNaN: define("number/is-nan", ["es.number.is-nan"]),
isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]),
parseFloat: define("number/parse-float", ["es.number.parse-float"]),
parseInt: define("number/parse-int", ["es.number.parse-int"]),
range: define("number/range", ["esnext.number.range", "es.object.to-string"])
},
Object: {
assign: define("object/assign", ["es.object.assign"]),
create: define("object/create", ["es.object.create"]),
defineProperties: define("object/define-properties", ["es.object.define-properties"]),
defineProperty: define("object/define-property", ["es.object.define-property"]),
entries: define("object/entries", ["es.object.entries"]),
freeze: define("object/freeze", ["es.object.freeze"]),
fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]),
getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]),
getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]),
getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]),
getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]),
getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]),
groupBy: define("object/group-by", ["esnext.object.group-by", "es.object.create"]),
hasOwn: define("object/has-own", ["es.object.has-own"]),
is: define("object/is", ["es.object.is"]),
isExtensible: define("object/is-extensible", ["es.object.is-extensible"]),
isFrozen: define("object/is-frozen", ["es.object.is-frozen"]),
isSealed: define("object/is-sealed", ["es.object.is-sealed"]),
keys: define("object/keys", ["es.object.keys"]),
preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]),
seal: define("object/seal", ["es.object.seal"]),
setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]),
values: define("object/values", ["es.object.values"])
},
Promise: {
all: define(null, PromiseDependenciesWithIterators),
allSettled: define(null, ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
any: define(null, ["es.promise.any", "es.aggregate-error", ...PromiseDependenciesWithIterators]),
race: define(null, PromiseDependenciesWithIterators),
try: define(null, ["esnext.promise.try", ...PromiseDependencies]),
withResolvers: define(null, ["esnext.promise.with-resolvers", ...PromiseDependencies])
},
Reflect: {
apply: define("reflect/apply", ["es.reflect.apply"]),
construct: define("reflect/construct", ["es.reflect.construct"]),
defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]),
defineProperty: define("reflect/define-property", ["es.reflect.define-property"]),
deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]),
deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]),
get: define("reflect/get", ["es.reflect.get"]),
getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]),
getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]),
getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]),
getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]),
getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]),
getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]),
has: define("reflect/has", ["es.reflect.has"]),
hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]),
hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]),
isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]),
metadata: define("reflect/metadata", ["esnext.reflect.metadata"]),
ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]),
preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]),
set: define("reflect/set", ["es.reflect.set"]),
setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"])
},
RegExp: {
escape: define("regexp/escape", ["esnext.regexp.escape"])
},
Set: {
from: define(null, ["esnext.set.from", ...SetDependencies]),
of: define(null, ["esnext.set.of", ...SetDependencies])
},
String: {
cooked: define("string/cooked", ["esnext.string.cooked"]),
dedent: define("string/dedent", ["esnext.string.dedent", "es.string.from-code-point", "es.weak-map"]),
fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]),
raw: define("string/raw", ["es.string.raw"])
},
Symbol: {
asyncDispose: define("symbol/async-dispose", ["esnext.symbol.async-dispose", "esnext.async-iterator.async-dispose"]),
asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]),
dispose: define("symbol/dispose", ["esnext.symbol.dispose", "esnext.iterator.dispose"]),
for: define("symbol/for", [], "es.symbol"),
hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]),
isRegistered: define("symbol/is-registered", ["esnext.symbol.is-registered", "es.symbol"]),
isRegisteredSymbol: define("symbol/is-registered-symbol", ["esnext.symbol.is-registered-symbol", "es.symbol"]),
isWellKnown: define("symbol/is-well-known", ["esnext.symbol.is-well-known", "es.symbol"]),
isWellKnownSymbol: define("symbol/is-well-known-symbol", ["esnext.symbol.is-well-known-symbol", "es.symbol"]),
iterator: define("symbol/iterator", ["es.symbol.iterator", ...CommonIteratorsWithTag]),
keyFor: define("symbol/key-for", [], "es.symbol"),
match: define("symbol/match", ["es.symbol.match", "es.string.match"]),
matcher: define("symbol/matcher", ["esnext.symbol.matcher"]),
matchAll: define("symbol/match-all", ["es.symbol.match-all", "es.string.match-all"]),
metadata: define("symbol/metadata", DecoratorMetadataDependencies),
metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]),
observable: define("symbol/observable", ["esnext.symbol.observable"]),
patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]),
replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]),
search: define("symbol/search", ["es.symbol.search", "es.string.search"]),
species: define("symbol/species", ["es.symbol.species", "es.array.species"]),
split: define("symbol/split", ["es.symbol.split", "es.string.split"]),
toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]),
toStringTag: define("symbol/to-string-tag", ["es.symbol.to-string-tag", "es.object.to-string", "es.math.to-string-tag", "es.json.to-string-tag"]),
unscopables: define("symbol/unscopables", ["es.symbol.unscopables"])
},
URL: {
canParse: define("url/can-parse", ["web.url.can-parse", "web.url"])
},
WeakMap: {
from: define(null, ["esnext.weak-map.from", ...WeakMapDependencies]),
of: define(null, ["esnext.weak-map.of", ...WeakMapDependencies])
},
WeakSet: {
from: define(null, ["esnext.weak-set.from", ...WeakSetDependencies]),
of: define(null, ["esnext.weak-set.of", ...WeakSetDependencies])
},
Int8Array: TypedArrayStaticMethods,
Uint8Array: TypedArrayStaticMethods,
Uint8ClampedArray: TypedArrayStaticMethods,
Int16Array: TypedArrayStaticMethods,
Uint16Array: TypedArrayStaticMethods,
Int32Array: TypedArrayStaticMethods,
Uint32Array: TypedArrayStaticMethods,
Float32Array: TypedArrayStaticMethods,
Float64Array: TypedArrayStaticMethods,
WebAssembly: {
CompileError: define(null, ErrorDependencies),
LinkError: define(null, ErrorDependencies),
RuntimeError: define(null, ErrorDependencies)
}
};
const InstanceProperties = {
asIndexedPairs: define("instance/asIndexedPairs", ["esnext.async-iterator.as-indexed-pairs", ...AsyncIteratorDependencies, "esnext.iterator.as-indexed-pairs", ...IteratorDependencies]),
at: define("instance/at", [
// TODO: We should introduce overloaded instance methods definition
// Before that is implemented, the `esnext.string.at` must be the first
// In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at`
// and treats the compat-data of `esnext.string.at` as the compat-data of
// pure import `instance/at`. The first polyfill here should have the lowest corejs
// supported versions.
"esnext.string.at", "es.string.at-alternative", "es.array.at"]),
anchor: define(null, ["es.string.anchor"]),
big: define(null, ["es.string.big"]),
bind: define("instance/bind", ["es.function.bind"]),
blink: define(null, ["es.string.blink"]),
bold: define(null, ["es.string.bold"]),
codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]),
codePoints: define("instance/code-points", ["esnext.string.code-points"]),
concat: define("instance/concat", ["es.array.concat"], undefined, ["String"]),
copyWithin: define("instance/copy-within", ["es.array.copy-within"]),
demethodize: define("instance/demethodize", ["esnext.function.demethodize"]),
description: define(null, ["es.symbol", "es.symbol.description"]),
dotAll: define(null, ["es.regexp.dot-all"]),
drop: define(null, ["esnext.async-iterator.drop", ...AsyncIteratorDependencies, "esnext.iterator.drop", ...IteratorDependencies]),
emplace: define("instance/emplace", ["esnext.map.emplace", "esnext.weak-map.emplace"]),
endsWith: define("instance/ends-with", ["es.string.ends-with"]),
entries: define("instance/entries", ArrayNatureIteratorsWithTag),
every: define("instance/every", ["es.array.every", "esnext.async-iterator.every",
// TODO: add async iterator dependencies when we support sub-dependencies
// esnext.async-iterator.every depends on es.promise
// but we don't want to pull es.promise when esnext.async-iterator is disabled
//
// ...AsyncIteratorDependencies
"esnext.iterator.every", ...IteratorDependencies]),
exec: define(null, ["es.regexp.exec"]),
fill: define("instance/fill", ["es.array.fill"]),
filter: define("instance/filter", ["es.array.filter", "esnext.async-iterator.filter", "esnext.iterator.filter", ...IteratorDependencies]),
filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]),
finally: define(null, ["es.promise.finally", ...PromiseDependencies]),
find: define("instance/find", ["es.array.find", "esnext.async-iterator.find", "esnext.iterator.find", ...IteratorDependencies]),
findIndex: define("instance/find-index", ["es.array.find-index"]),
findLast: define("instance/find-last", ["es.array.find-last"]),
findLastIndex: define("instance/find-last-index", ["es.array.find-last-index"]),
fixed: define(null, ["es.string.fixed"]),
flags: define("instance/flags", ["es.regexp.flags"]),
flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map", "esnext.async-iterator.flat-map", "esnext.iterator.flat-map", ...IteratorDependencies]),
flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]),
getFloat16: define(null, ["esnext.data-view.get-float16", ...DataViewDependencies]),
getUint8Clamped: define(null, ["esnext.data-view.get-uint8-clamped", ...DataViewDependencies]),
getYear: define(null, ["es.date.get-year"]),
group: define("instance/group", ["esnext.array.group"]),
groupBy: define("instance/group-by", ["esnext.array.group-by"]),
groupByToMap: define("instance/group-by-to-map", ["esnext.array.group-by-to-map", "es.map", "es.object.to-string"]),
groupToMap: define("instance/group-to-map", ["esnext.array.group-to-map", "es.map", "es.object.to-string"]),
fontcolor: define(null, ["es.string.fontcolor"]),
fontsize: define(null, ["es.string.fontsize"]),
forEach: define("instance/for-each", ["es.array.for-each", "esnext.async-iterator.for-each", "esnext.iterator.for-each", ...IteratorDependencies, "web.dom-collections.for-each"]),
includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
indexed: define(null, ["esnext.async-iterator.indexed", ...AsyncIteratorDependencies, "esnext.iterator.indexed", ...IteratorDependencies]),
indexOf: define("instance/index-of", ["es.array.index-of"]),
isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]),
italic: define(null, ["es.string.italics"]),
join: define(null, ["es.array.join"]),
keys: define("instance/keys", ArrayNatureIteratorsWithTag),
lastIndex: define(null, ["esnext.array.last-index"]),
lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]),
lastItem: define(null, ["esnext.array.last-item"]),
link: define(null, ["es.string.link"]),
map: define("instance/map", ["es.array.map", "esnext.async-iterator.map", "esnext.iterator.map"]),
match: define(null, ["es.string.match", "es.regexp.exec"]),
matchAll: define("instance/match-all", ["es.string.match-all", "es.regexp.exec"]),
name: define(null, ["es.function.name"]),
padEnd: define("instance/pad-end", ["es.string.pad-end"]),
padStart: define("instance/pad-start", ["es.string.pad-start"]),
push: define("instance/push", ["es.array.push"]),
reduce: define("instance/reduce", ["es.array.reduce", "esnext.async-iterator.reduce", "esnext.iterator.reduce", ...IteratorDependencies]),
reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]),
repeat: define("instance/repeat", ["es.string.repeat"]),
replace: define(null, ["es.string.replace", "es.regexp.exec"]),
replaceAll: define("instance/replace-all", ["es.string.replace-all", "es.string.replace", "es.regexp.exec"]),
reverse: define("instance/reverse", ["es.array.reverse"]),
search: define(null, ["es.string.search", "es.regexp.exec"]),
setFloat16: define(null, ["esnext.data-view.set-float16", ...DataViewDependencies]),
setUint8Clamped: define(null, ["esnext.data-view.set-uint8-clamped", ...DataViewDependencies]),
setYear: define(null, ["es.date.set-year"]),
slice: define("instance/slice", ["es.array.slice"]),
small: define(null, ["es.string.small"]),
some: define("instance/some", ["es.array.some", "esnext.async-iterator.some", "esnext.iterator.some", ...IteratorDependencies]),
sort: define("instance/sort", ["es.array.sort"]),
splice: define("instance/splice", ["es.array.splice"]),
split: define(null, ["es.string.split", "es.regexp.exec"]),
startsWith: define("instance/starts-with", ["es.string.starts-with"]),
sticky: define(null, ["es.regexp.sticky"]),
strike: define(null, ["es.string.strike"]),
sub: define(null, ["es.string.sub"]),
substr: define(null, ["es.string.substr"]),
sup: define(null, ["es.string.sup"]),
take: define(null, ["esnext.async-iterator.take", ...AsyncIteratorDependencies, "esnext.iterator.take", ...IteratorDependencies]),
test: define(null, ["es.regexp.test", "es.regexp.exec"]),
toArray: define(null, ["esnext.async-iterator.to-array", ...AsyncIteratorDependencies, "esnext.iterator.to-array", ...IteratorDependencies]),
toAsync: define(null, ["esnext.iterator.to-async", ...IteratorDependencies, ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods]),
toExponential: define(null, ["es.number.to-exponential"]),
toFixed: define(null, ["es.number.to-fixed"]),
toGMTString: define(null, ["es.date.to-gmt-string"]),
toISOString: define(null, ["es.date.to-iso-string"]),
toJSON: define(null, ["es.date.to-json", "web.url.to-json"]),
toPrecision: define(null, ["es.number.to-precision"]),
toReversed: define("instance/to-reversed", ["es.array.to-reversed"]),
toSorted: define("instance/to-sorted", ["es.array.to-sorted", "es.array.sort"]),
toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]),
toString: define(null, ["es.object.to-string", "es.error.to-string", "es.date.to-string", "es.regexp.to-string"]),
toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]),
trim: define("instance/trim", ["es.string.trim"]),
trimEnd: define("instance/trim-end", ["es.string.trim-end"]),
trimLeft: define("instance/trim-left", ["es.string.trim-start"]),
trimRight: define("instance/trim-right", ["es.string.trim-end"]),
trimStart: define("instance/trim-start", ["es.string.trim-start"]),
uniqueBy: define("instance/unique-by", ["esnext.array.unique-by", "es.map"]),
unshift: define("instance/unshift", ["es.array.unshift"]),
unThis: define("instance/un-this", ["esnext.function.un-this"]),
values: define("instance/values", ArrayNatureIteratorsWithTag),
with: define("instance/with", ["es.array.with"]),
__defineGetter__: define(null, ["es.object.define-getter"]),
__defineSetter__: define(null, ["es.object.define-setter"]),
__lookupGetter__: define(null, ["es.object.lookup-getter"]),
__lookupSetter__: define(null, ["es.object.lookup-setter"]),
["__proto__"]: define(null, ["es.object.proto"])
};
const {
types: t$2
} = _babel.default || _babel;
function canSkipPolyfill(desc, path) {
const {
node,
parent
} = path;
switch (desc.name) {
case "es.string.split":
{
if (!t$2.isCallExpression(parent, {
callee: node
})) return false;
if (parent.arguments.length < 1) return true;
const splitter = parent.arguments[0];
return t$2.isStringLiteral(splitter) || t$2.isTemplateLiteral(splitter);
}
}
}
const {
types: t$1
} = _babel.default || _babel;
const BABEL_RUNTIME = "@babel/runtime-corejs3";
function callMethod(path, id) {
const {
object
} = path.node;
let context1, context2;
if (t$1.isIdentifier(object)) {
context1 = object;
context2 = t$1.cloneNode(object);
} else {
context1 = path.scope.generateDeclaredUidIdentifier("context");
context2 = t$1.assignmentExpression("=", t$1.cloneNode(context1), object);
}
path.replaceWith(t$1.memberExpression(t$1.callExpression(id, [context2]), t$1.identifier("call")));
path.parentPath.unshiftContainer("arguments", context1);
}
function isCoreJSSource(source) {
if (typeof source === "string") {
source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
}
return Object.prototype.hasOwnProperty.call(corejsEntries, source) && corejsEntries[source];
}
function coreJSModule(name) {
return `core-js/modules/${name}.js`;
}
function coreJSPureHelper(name, useBabelRuntime, ext) {
return useBabelRuntime ? `${BABEL_RUNTIME}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
}
const {
types: t
} = _babel.default || _babel;
const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility";
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
const uniqueObjects = ["array", "string", "iterator", "async-iterator", "dom-collections"].map(v => new RegExp(`[a-z]*\\.${v}\\..*`));
const esnextFallback = (name, cb) => {
if (cb(name)) return true;
if (!name.startsWith("es.")) return false;
const fallback = `esnext.${name.slice(3)}`;
if (!corejs3Polyfills[fallback]) return false;
return cb(fallback);
};
var index = defineProvider(function ({
getUtils,
method,
shouldInjectPolyfill,
createMetaResolver,
debug,
babel
}, {
version = 3,
proposals,
shippedProposals,
[presetEnvCompat]: {
noRuntimeName = false
} = {},
[runtimeCompat]: {
useBabelRuntime = false,
ext = ".js"
} = {}
}) {
const isWebpack = babel.caller(caller => (caller == null ? void 0 : caller.name) === "babel-loader");
const resolve = createMetaResolver({
global: BuiltIns,
static: StaticProperties,
instance: InstanceProperties
});
const available = new Set(getModulesListForTargetVersion(version));
function getCoreJSPureBase(useProposalBase) {
return useBabelRuntime ? useProposalBase ? `${BABEL_RUNTIME}/core-js` : `${BABEL_RUNTIME}/core-js-stable` : useProposalBase ? "core-js-pure/features" : "core-js-pure/stable";
}
function maybeInjectGlobalImpl(name, utils) {
if (shouldInjectPolyfill(name)) {
debug(name);
utils.injectGlobalImport(coreJSModule(name));
return true;
}
return false;
}
function maybeInjectGlobal(names, utils, fallback = true) {
for (const name of names) {
if (fallback) {
esnextFallback(name, name => maybeInjectGlobalImpl(name, utils));
} else {
maybeInjectGlobalImpl(name, utils);
}
}
}
function maybeInjectPure(desc, hint, utils, object) {
if (desc.pure && !(object && desc.exclude && desc.exclude.includes(object)) && esnextFallback(desc.name, shouldInjectPolyfill)) {
const {
name
} = desc;
let useProposalBase = false;
if (proposals || shippedProposals && name.startsWith("esnext.")) {
useProposalBase = true;
} else if (name.startsWith("es.") && !available.has(name)) {
useProposalBase = true;
}
const coreJSPureBase = getCoreJSPureBase(useProposalBase);
return utils.injectDefaultImport(`${coreJSPureBase}/${desc.pure}${ext}`, hint);
}
}
function isFeatureStable(name) {
if (name.startsWith("esnext.")) {
const esName = `es.${name.slice(7)}`;
// If its imaginative esName is not in latest compat data, it means
// the proposal is not stage 4
return esName in corejs3Polyfills;
}
return true;
}
return {
name: "corejs3",
runtimeName: noRuntimeName ? null : BABEL_RUNTIME,
polyfills: corejs3Polyfills,
filterPolyfills(name) {
if (!available.has(name)) return false;
if (proposals || method === "entry-global") return true;
if (shippedProposals && corejs3ShippedProposalsList.has(name)) {
return true;
}
return isFeatureStable(name);
},
entryGlobal(meta, utils, path) {
if (meta.kind !== "import") return;
const modules = isCoreJSSource(meta.source);
if (!modules) return;
if (modules.length === 1 && meta.source === coreJSModule(modules[0]) && shouldInjectPolyfill(modules[0])) {
// Avoid infinite loop: do not replace imports with a new copy of
// themselves.
debug(null);
return;
}
const modulesSet = new Set(modules);
const filteredModules = modules.filter(module => {
if (!module.startsWith("esnext.")) return true;
const stable = module.replace("esnext.", "es.");
if (modulesSet.has(stable) && shouldInjectPolyfill(stable)) {
return false;
}
return true;
});
maybeInjectGlobal(filteredModules, utils, false);
path.remove();
},
usageGlobal(meta, utils, path) {
const resolved = resolve(meta);
if (!resolved) return;
if (canSkipPolyfill(resolved.desc, path)) return;
let deps = resolved.desc.global;
if (resolved.kind !== "global" && "object" in meta && meta.object && meta.placement === "prototype") {
const low = meta.object.toLowerCase();
deps = deps.filter(m => uniqueObjects.some(v => v.test(m)) ? m.includes(low) : true);
}
maybeInjectGlobal(deps, utils);
},
usagePure(meta, utils, path) {
if (meta.kind === "in") {
if (meta.key === "Symbol.iterator") {
path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("is-iterable", useBabelRuntime, ext), "isIterable"), [path.node.right] // meta.kind === "in" narrows this
));
}
return;
}
if (path.parentPath.isUnaryExpression({
operator: "delete"
})) return;
if (meta.kind === "property") {
// We can't compile destructuring and updateExpression.
if (!path.isMemberExpression()) return;
if (!path.isReferenced()) return;
if (path.parentPath.isUpdateExpression()) return;
if (t.isSuper(path.node.object)) {
return;
}
if (meta.key === "Symbol.iterator") {
if (!shouldInjectPolyfill("es.symbol.iterator")) return;
const {
parent,
node
} = path;
if (t.isCallExpression(parent, {
callee: node
})) {
if (parent.arguments.length === 0) {
path.parentPath.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator", useBabelRuntime, ext), "getIterator"), [node.object]));
path.skip();
} else {
callMethod(path, utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"));
}
} else {
path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"), [path.node.object]));
}
return;
}
}
let resolved = resolve(meta);
if (!resolved) return;
if (canSkipPolyfill(resolved.desc, path)) return;
if (useBabelRuntime && resolved.desc.pure && resolved.desc.pure.slice(-6) === "/index") {
// Remove /index, since it doesn't exist in @babel/runtime-corejs3s
resolved = {
...resolved,
desc: {
...resolved.desc,
pure: resolved.desc.pure.slice(0, -6)
}
};
}
if (resolved.kind === "global") {
const id = maybeInjectPure(resolved.desc, resolved.name, utils);
if (id) path.replaceWith(id);
} else if (resolved.kind === "static") {
const id = maybeInjectPure(resolved.desc, resolved.name, utils,
// @ts-expect-error
meta.object);
if (id) path.replaceWith(id);
} else if (resolved.kind === "instance") {
const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
// @ts-expect-error
meta.object);
if (!id) return;
const {
node
} = path;
if (t.isCallExpression(path.parent, {
callee: node
})) {
callMethod(path, id);
} else {
path.replaceWith(t.callExpression(id, [node.object]));
}
}
},
visitor: method === "usage-global" && {
// import("foo")
CallExpression(path) {
if (path.get("callee").isImport()) {
const utils = getUtils(path);
if (isWebpack) {
// Webpack uses Promise.all to handle dynamic import.
maybeInjectGlobal(PromiseDependenciesWithIterators, utils);
} else {
maybeInjectGlobal(PromiseDependencies, utils);
}
}
},
// (async function () { }).finally(...)
Function(path) {
if (path.node.async) {
maybeInjectGlobal(PromiseDependencies, getUtils(path));
}
},
// for-of, [a, b] = c
"ForOfStatement|ArrayPattern"(path) {
maybeInjectGlobal(CommonIterators, getUtils(path));
},
// [...spread]
SpreadElement(path) {
if (!path.parentPath.isObjectExpression()) {
maybeInjectGlobal(CommonIterators, getUtils(path));
}
},
// yield*
YieldExpression(path) {
if (path.node.delegate) {
maybeInjectGlobal(CommonIterators, getUtils(path));
}
},
// Decorators metadata
Class(path) {
var _path$node$decorators;
const hasDecorators = ((_path$node$decorators = path.node.decorators) == null ? void 0 : _path$node$decorators.length) || path.node.body.body.some(el => {
var _decorators;
return (_decorators = el.decorators) == null ? void 0 : _decorators.length;
});
if (hasDecorators) {
maybeInjectGlobal(DecoratorMetadataDependencies, getUtils(path));
}
}
}
};
});
export default index;
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,446 @@
"use strict";
exports.__esModule = true;
exports.StaticProperties = exports.PromiseDependenciesWithIterators = exports.PromiseDependencies = exports.InstanceProperties = exports.DecoratorMetadataDependencies = exports.CommonIterators = exports.BuiltIns = void 0;
var _data = _interopRequireDefault(require("../core-js-compat/data.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const polyfillsOrder = {};
Object.keys(_data.default).forEach((name, index) => {
polyfillsOrder[name] = index;
});
const define = (pure, global, name = global[0], exclude) => {
return {
name,
pure,
global: global.sort((a, b) => polyfillsOrder[a] - polyfillsOrder[b]),
exclude
};
};
const typed = name => define(null, [name, ...TypedArrayDependencies]);
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 ErrorDependencies = ["es.error.cause", "es.error.to-string"];
const SuppressedErrorDependencies = ["esnext.suppressed-error.constructor", ...ErrorDependencies];
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", "es.array-buffer.slice", "esnext.array-buffer.detached", "esnext.array-buffer.transfer", "esnext.array-buffer.transfer-to-fixed-length", "esnext.typed-array.filter-reject", "esnext.typed-array.group-by", "esnext.typed-array.to-spliced", "esnext.typed-array.unique-by"];
const PromiseDependencies = ["es.promise", "es.object.to-string"];
exports.PromiseDependencies = PromiseDependencies;
const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
exports.PromiseDependenciesWithIterators = PromiseDependenciesWithIterators;
const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
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];
const SetDependencies = ["es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.difference.v2", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.intersection.v2", "esnext.set.is-disjoint-from", "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of", "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of", "esnext.set.is-superset-of.v2", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.symmetric-difference.v2", "esnext.set.union", "esnext.set.union.v2", ...CommonIteratorsWithTag];
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", ...CommonIteratorsWithTag];
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
const DOMExceptionDependencies = ["web.dom-exception.constructor", "web.dom-exception.stack", "web.dom-exception.to-string-tag", "es.error.to-string"];
const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.delete", "web.url-search-params.has", "web.url-search-params.size", ...CommonIteratorsWithTag];
const AsyncIteratorDependencies = ["esnext.async-iterator.constructor", ...PromiseDependencies];
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"];
const IteratorDependencies = ["esnext.iterator.constructor", "es.object.to-string"];
const DecoratorMetadataDependencies = ["esnext.symbol.metadata", "esnext.function.metadata"];
exports.DecoratorMetadataDependencies = DecoratorMetadataDependencies;
const TypedArrayStaticMethods = {
from: define(null, ["es.typed-array.from"]),
fromAsync: define(null, ["esnext.typed-array.from-async", ...PromiseDependenciesWithIterators]),
of: define(null, ["es.typed-array.of"])
};
const DataViewDependencies = ["es.data-view", "es.array-buffer.slice", "es.object.to-string"];
const BuiltIns = {
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]),
AsyncIterator: define("async-iterator/index", AsyncIteratorDependencies),
AggregateError: define("aggregate-error", ["es.aggregate-error", ...ErrorDependencies, ...CommonIteratorsWithTag, "es.aggregate-error.cause"]),
ArrayBuffer: define(null, ["es.array-buffer.constructor", "es.array-buffer.slice", "es.object.to-string"]),
DataView: define(null, DataViewDependencies),
Date: define(null, ["es.date.to-string"]),
DOMException: define("dom-exception/index", DOMExceptionDependencies),
DisposableStack: define("disposable-stack/index", ["esnext.disposable-stack.constructor", "es.object.to-string", "esnext.iterator.dispose", ...SuppressedErrorDependencies]),
Error: define(null, ErrorDependencies),
EvalError: define(null, ErrorDependencies),
Float32Array: typed("es.typed-array.float32-array"),
Float64Array: typed("es.typed-array.float64-array"),
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", IteratorDependencies),
Uint8Array: typed("es.typed-array.uint8-array"),
Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
Uint16Array: typed("es.typed-array.uint16-array"),
Uint32Array: typed("es.typed-array.uint32-array"),
Map: define("map/index", MapDependencies),
Number: define(null, ["es.number.constructor"]),
Observable: define("observable/index", ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag]),
Promise: define("promise/index", PromiseDependencies),
RangeError: define(null, ErrorDependencies),
ReferenceError: define(null, ErrorDependencies),
Reflect: define(null, ["es.reflect.to-string-tag", "es.object.to-string"]),
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),
SuppressedError: define("suppressed-error", SuppressedErrorDependencies),
Symbol: define("symbol/index", SymbolDependencies),
SyntaxError: define(null, ErrorDependencies),
TypeError: define(null, ErrorDependencies),
URIError: define(null, ErrorDependencies),
URL: define("url/index", ["web.url", ...URLSearchParamsDependencies]),
URLSearchParams: define("url-search-params/index", URLSearchParamsDependencies),
WeakMap: define("weak-map/index", WeakMapDependencies),
WeakSet: define("weak-set/index", WeakSetDependencies),
atob: define("atob", ["web.atob", ...DOMExceptionDependencies]),
btoa: define("btoa", ["web.btoa", ...DOMExceptionDependencies]),
clearImmediate: define("clear-immediate", ["web.immediate"]),
compositeKey: define("composite-key", ["esnext.composite-key"]),
compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]),
escape: define("escape", ["es.escape"]),
fetch: define(null, PromiseDependencies),
globalThis: define("global-this", ["es.global-this"]),
parseFloat: define("parse-float", ["es.parse-float"]),
parseInt: define("parse-int", ["es.parse-int"]),
queueMicrotask: define("queue-microtask", ["web.queue-microtask"]),
self: define("self", ["web.self"]),
setImmediate: define("set-immediate", ["web.immediate"]),
setInterval: define("set-interval", ["web.timers"]),
setTimeout: define("set-timeout", ["web.timers"]),
structuredClone: define("structured-clone", ["web.structured-clone", ...DOMExceptionDependencies, "es.array.iterator", "es.object.keys", "es.object.to-string", "es.map", "es.set"]),
unescape: define("unescape", ["es.unescape"])
};
exports.BuiltIns = BuiltIns;
const StaticProperties = {
AsyncIterator: {
from: define("async-iterator/from", ["esnext.async-iterator.from", ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods, ...CommonIterators])
},
Array: {
from: define("array/from", ["es.array.from", "es.string.iterator"]),
fromAsync: define("array/from-async", ["esnext.array.from-async", ...PromiseDependenciesWithIterators]),
isArray: define("array/is-array", ["es.array.is-array"]),
isTemplateObject: define("array/is-template-object", ["esnext.array.is-template-object"]),
of: define("array/of", ["es.array.of"])
},
ArrayBuffer: {
isView: define(null, ["es.array-buffer.is-view"])
},
BigInt: {
range: define("bigint/range", ["esnext.bigint.range", "es.object.to-string"])
},
Date: {
now: define("date/now", ["es.date.now"])
},
Function: {
isCallable: define("function/is-callable", ["esnext.function.is-callable"]),
isConstructor: define("function/is-constructor", ["esnext.function.is-constructor"])
},
Iterator: {
from: define("iterator/from", ["esnext.iterator.from", ...IteratorDependencies, ...CommonIterators]),
range: define("iterator/range", ["esnext.iterator.range", "es.object.to-string"])
},
JSON: {
isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]),
parse: define("json/parse", ["esnext.json.parse", "es.object.keys"]),
rawJSON: define("json/raw-json", ["esnext.json.raw-json", "es.object.create", "es.object.freeze"]),
stringify: define("json/stringify", ["es.json.stringify"], "es.symbol")
},
Math: {
DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]),
RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]),
acosh: define("math/acosh", ["es.math.acosh"]),
asinh: define("math/asinh", ["es.math.asinh"]),
atanh: define("math/atanh", ["es.math.atanh"]),
cbrt: define("math/cbrt", ["es.math.cbrt"]),
clamp: define("math/clamp", ["esnext.math.clamp"]),
clz32: define("math/clz32", ["es.math.clz32"]),
cosh: define("math/cosh", ["es.math.cosh"]),
degrees: define("math/degrees", ["esnext.math.degrees"]),
expm1: define("math/expm1", ["es.math.expm1"]),
fround: define("math/fround", ["es.math.fround"]),
f16round: define("math/f16round", ["esnext.math.f16round"]),
fscale: define("math/fscale", ["esnext.math.fscale"]),
hypot: define("math/hypot", ["es.math.hypot"]),
iaddh: define("math/iaddh", ["esnext.math.iaddh"]),
imul: define("math/imul", ["es.math.imul"]),
imulh: define("math/imulh", ["esnext.math.imulh"]),
isubh: define("math/isubh", ["esnext.math.isubh"]),
log10: define("math/log10", ["es.math.log10"]),
log1p: define("math/log1p", ["es.math.log1p"]),
log2: define("math/log2", ["es.math.log2"]),
radians: define("math/radians", ["esnext.math.radians"]),
scale: define("math/scale", ["esnext.math.scale"]),
seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]),
sign: define("math/sign", ["es.math.sign"]),
signbit: define("math/signbit", ["esnext.math.signbit"]),
sinh: define("math/sinh", ["es.math.sinh"]),
tanh: define("math/tanh", ["es.math.tanh"]),
trunc: define("math/trunc", ["es.math.trunc"]),
umulh: define("math/umulh", ["esnext.math.umulh"])
},
Map: {
from: define(null, ["esnext.map.from", ...MapDependencies]),
groupBy: define(null, ["esnext.map.group-by", ...MapDependencies]),
keyBy: define(null, ["esnext.map.key-by", ...MapDependencies]),
of: define(null, ["esnext.map.of", ...MapDependencies])
},
Number: {
EPSILON: define("number/epsilon", ["es.number.epsilon"]),
MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]),
MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]),
fromString: define("number/from-string", ["esnext.number.from-string"]),
isFinite: define("number/is-finite", ["es.number.is-finite"]),
isInteger: define("number/is-integer", ["es.number.is-integer"]),
isNaN: define("number/is-nan", ["es.number.is-nan"]),
isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]),
parseFloat: define("number/parse-float", ["es.number.parse-float"]),
parseInt: define("number/parse-int", ["es.number.parse-int"]),
range: define("number/range", ["esnext.number.range", "es.object.to-string"])
},
Object: {
assign: define("object/assign", ["es.object.assign"]),
create: define("object/create", ["es.object.create"]),
defineProperties: define("object/define-properties", ["es.object.define-properties"]),
defineProperty: define("object/define-property", ["es.object.define-property"]),
entries: define("object/entries", ["es.object.entries"]),
freeze: define("object/freeze", ["es.object.freeze"]),
fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]),
getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]),
getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]),
getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]),
getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]),
getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]),
groupBy: define("object/group-by", ["esnext.object.group-by", "es.object.create"]),
hasOwn: define("object/has-own", ["es.object.has-own"]),
is: define("object/is", ["es.object.is"]),
isExtensible: define("object/is-extensible", ["es.object.is-extensible"]),
isFrozen: define("object/is-frozen", ["es.object.is-frozen"]),
isSealed: define("object/is-sealed", ["es.object.is-sealed"]),
keys: define("object/keys", ["es.object.keys"]),
preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]),
seal: define("object/seal", ["es.object.seal"]),
setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]),
values: define("object/values", ["es.object.values"])
},
Promise: {
all: define(null, PromiseDependenciesWithIterators),
allSettled: define(null, ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
any: define(null, ["es.promise.any", "es.aggregate-error", ...PromiseDependenciesWithIterators]),
race: define(null, PromiseDependenciesWithIterators),
try: define(null, ["esnext.promise.try", ...PromiseDependencies]),
withResolvers: define(null, ["esnext.promise.with-resolvers", ...PromiseDependencies])
},
Reflect: {
apply: define("reflect/apply", ["es.reflect.apply"]),
construct: define("reflect/construct", ["es.reflect.construct"]),
defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]),
defineProperty: define("reflect/define-property", ["es.reflect.define-property"]),
deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]),
deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]),
get: define("reflect/get", ["es.reflect.get"]),
getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]),
getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]),
getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]),
getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]),
getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]),
getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]),
has: define("reflect/has", ["es.reflect.has"]),
hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]),
hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]),
isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]),
metadata: define("reflect/metadata", ["esnext.reflect.metadata"]),
ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]),
preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]),
set: define("reflect/set", ["es.reflect.set"]),
setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"])
},
RegExp: {
escape: define("regexp/escape", ["esnext.regexp.escape"])
},
Set: {
from: define(null, ["esnext.set.from", ...SetDependencies]),
of: define(null, ["esnext.set.of", ...SetDependencies])
},
String: {
cooked: define("string/cooked", ["esnext.string.cooked"]),
dedent: define("string/dedent", ["esnext.string.dedent", "es.string.from-code-point", "es.weak-map"]),
fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]),
raw: define("string/raw", ["es.string.raw"])
},
Symbol: {
asyncDispose: define("symbol/async-dispose", ["esnext.symbol.async-dispose", "esnext.async-iterator.async-dispose"]),
asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]),
dispose: define("symbol/dispose", ["esnext.symbol.dispose", "esnext.iterator.dispose"]),
for: define("symbol/for", [], "es.symbol"),
hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]),
isRegistered: define("symbol/is-registered", ["esnext.symbol.is-registered", "es.symbol"]),
isRegisteredSymbol: define("symbol/is-registered-symbol", ["esnext.symbol.is-registered-symbol", "es.symbol"]),
isWellKnown: define("symbol/is-well-known", ["esnext.symbol.is-well-known", "es.symbol"]),
isWellKnownSymbol: define("symbol/is-well-known-symbol", ["esnext.symbol.is-well-known-symbol", "es.symbol"]),
iterator: define("symbol/iterator", ["es.symbol.iterator", ...CommonIteratorsWithTag]),
keyFor: define("symbol/key-for", [], "es.symbol"),
match: define("symbol/match", ["es.symbol.match", "es.string.match"]),
matcher: define("symbol/matcher", ["esnext.symbol.matcher"]),
matchAll: define("symbol/match-all", ["es.symbol.match-all", "es.string.match-all"]),
metadata: define("symbol/metadata", DecoratorMetadataDependencies),
metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]),
observable: define("symbol/observable", ["esnext.symbol.observable"]),
patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]),
replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]),
search: define("symbol/search", ["es.symbol.search", "es.string.search"]),
species: define("symbol/species", ["es.symbol.species", "es.array.species"]),
split: define("symbol/split", ["es.symbol.split", "es.string.split"]),
toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]),
toStringTag: define("symbol/to-string-tag", ["es.symbol.to-string-tag", "es.object.to-string", "es.math.to-string-tag", "es.json.to-string-tag"]),
unscopables: define("symbol/unscopables", ["es.symbol.unscopables"])
},
URL: {
canParse: define("url/can-parse", ["web.url.can-parse", "web.url"])
},
WeakMap: {
from: define(null, ["esnext.weak-map.from", ...WeakMapDependencies]),
of: define(null, ["esnext.weak-map.of", ...WeakMapDependencies])
},
WeakSet: {
from: define(null, ["esnext.weak-set.from", ...WeakSetDependencies]),
of: define(null, ["esnext.weak-set.of", ...WeakSetDependencies])
},
Int8Array: TypedArrayStaticMethods,
Uint8Array: TypedArrayStaticMethods,
Uint8ClampedArray: TypedArrayStaticMethods,
Int16Array: TypedArrayStaticMethods,
Uint16Array: TypedArrayStaticMethods,
Int32Array: TypedArrayStaticMethods,
Uint32Array: TypedArrayStaticMethods,
Float32Array: TypedArrayStaticMethods,
Float64Array: TypedArrayStaticMethods,
WebAssembly: {
CompileError: define(null, ErrorDependencies),
LinkError: define(null, ErrorDependencies),
RuntimeError: define(null, ErrorDependencies)
}
};
exports.StaticProperties = StaticProperties;
const InstanceProperties = {
asIndexedPairs: define("instance/asIndexedPairs", ["esnext.async-iterator.as-indexed-pairs", ...AsyncIteratorDependencies, "esnext.iterator.as-indexed-pairs", ...IteratorDependencies]),
at: define("instance/at", [
// TODO: We should introduce overloaded instance methods definition
// Before that is implemented, the `esnext.string.at` must be the first
// In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at`
// and treats the compat-data of `esnext.string.at` as the compat-data of
// pure import `instance/at`. The first polyfill here should have the lowest corejs
// supported versions.
"esnext.string.at", "es.string.at-alternative", "es.array.at"]),
anchor: define(null, ["es.string.anchor"]),
big: define(null, ["es.string.big"]),
bind: define("instance/bind", ["es.function.bind"]),
blink: define(null, ["es.string.blink"]),
bold: define(null, ["es.string.bold"]),
codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]),
codePoints: define("instance/code-points", ["esnext.string.code-points"]),
concat: define("instance/concat", ["es.array.concat"], undefined, ["String"]),
copyWithin: define("instance/copy-within", ["es.array.copy-within"]),
demethodize: define("instance/demethodize", ["esnext.function.demethodize"]),
description: define(null, ["es.symbol", "es.symbol.description"]),
dotAll: define(null, ["es.regexp.dot-all"]),
drop: define(null, ["esnext.async-iterator.drop", ...AsyncIteratorDependencies, "esnext.iterator.drop", ...IteratorDependencies]),
emplace: define("instance/emplace", ["esnext.map.emplace", "esnext.weak-map.emplace"]),
endsWith: define("instance/ends-with", ["es.string.ends-with"]),
entries: define("instance/entries", ArrayNatureIteratorsWithTag),
every: define("instance/every", ["es.array.every", "esnext.async-iterator.every",
// TODO: add async iterator dependencies when we support sub-dependencies
// esnext.async-iterator.every depends on es.promise
// but we don't want to pull es.promise when esnext.async-iterator is disabled
//
// ...AsyncIteratorDependencies
"esnext.iterator.every", ...IteratorDependencies]),
exec: define(null, ["es.regexp.exec"]),
fill: define("instance/fill", ["es.array.fill"]),
filter: define("instance/filter", ["es.array.filter", "esnext.async-iterator.filter", "esnext.iterator.filter", ...IteratorDependencies]),
filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]),
finally: define(null, ["es.promise.finally", ...PromiseDependencies]),
find: define("instance/find", ["es.array.find", "esnext.async-iterator.find", "esnext.iterator.find", ...IteratorDependencies]),
findIndex: define("instance/find-index", ["es.array.find-index"]),
findLast: define("instance/find-last", ["es.array.find-last"]),
findLastIndex: define("instance/find-last-index", ["es.array.find-last-index"]),
fixed: define(null, ["es.string.fixed"]),
flags: define("instance/flags", ["es.regexp.flags"]),
flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map", "esnext.async-iterator.flat-map", "esnext.iterator.flat-map", ...IteratorDependencies]),
flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]),
getFloat16: define(null, ["esnext.data-view.get-float16", ...DataViewDependencies]),
getUint8Clamped: define(null, ["esnext.data-view.get-uint8-clamped", ...DataViewDependencies]),
getYear: define(null, ["es.date.get-year"]),
group: define("instance/group", ["esnext.array.group"]),
groupBy: define("instance/group-by", ["esnext.array.group-by"]),
groupByToMap: define("instance/group-by-to-map", ["esnext.array.group-by-to-map", "es.map", "es.object.to-string"]),
groupToMap: define("instance/group-to-map", ["esnext.array.group-to-map", "es.map", "es.object.to-string"]),
fontcolor: define(null, ["es.string.fontcolor"]),
fontsize: define(null, ["es.string.fontsize"]),
forEach: define("instance/for-each", ["es.array.for-each", "esnext.async-iterator.for-each", "esnext.iterator.for-each", ...IteratorDependencies, "web.dom-collections.for-each"]),
includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
indexed: define(null, ["esnext.async-iterator.indexed", ...AsyncIteratorDependencies, "esnext.iterator.indexed", ...IteratorDependencies]),
indexOf: define("instance/index-of", ["es.array.index-of"]),
isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]),
italic: define(null, ["es.string.italics"]),
join: define(null, ["es.array.join"]),
keys: define("instance/keys", ArrayNatureIteratorsWithTag),
lastIndex: define(null, ["esnext.array.last-index"]),
lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]),
lastItem: define(null, ["esnext.array.last-item"]),
link: define(null, ["es.string.link"]),
map: define("instance/map", ["es.array.map", "esnext.async-iterator.map", "esnext.iterator.map"]),
match: define(null, ["es.string.match", "es.regexp.exec"]),
matchAll: define("instance/match-all", ["es.string.match-all", "es.regexp.exec"]),
name: define(null, ["es.function.name"]),
padEnd: define("instance/pad-end", ["es.string.pad-end"]),
padStart: define("instance/pad-start", ["es.string.pad-start"]),
push: define("instance/push", ["es.array.push"]),
reduce: define("instance/reduce", ["es.array.reduce", "esnext.async-iterator.reduce", "esnext.iterator.reduce", ...IteratorDependencies]),
reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]),
repeat: define("instance/repeat", ["es.string.repeat"]),
replace: define(null, ["es.string.replace", "es.regexp.exec"]),
replaceAll: define("instance/replace-all", ["es.string.replace-all", "es.string.replace", "es.regexp.exec"]),
reverse: define("instance/reverse", ["es.array.reverse"]),
search: define(null, ["es.string.search", "es.regexp.exec"]),
setFloat16: define(null, ["esnext.data-view.set-float16", ...DataViewDependencies]),
setUint8Clamped: define(null, ["esnext.data-view.set-uint8-clamped", ...DataViewDependencies]),
setYear: define(null, ["es.date.set-year"]),
slice: define("instance/slice", ["es.array.slice"]),
small: define(null, ["es.string.small"]),
some: define("instance/some", ["es.array.some", "esnext.async-iterator.some", "esnext.iterator.some", ...IteratorDependencies]),
sort: define("instance/sort", ["es.array.sort"]),
splice: define("instance/splice", ["es.array.splice"]),
split: define(null, ["es.string.split", "es.regexp.exec"]),
startsWith: define("instance/starts-with", ["es.string.starts-with"]),
sticky: define(null, ["es.regexp.sticky"]),
strike: define(null, ["es.string.strike"]),
sub: define(null, ["es.string.sub"]),
substr: define(null, ["es.string.substr"]),
sup: define(null, ["es.string.sup"]),
take: define(null, ["esnext.async-iterator.take", ...AsyncIteratorDependencies, "esnext.iterator.take", ...IteratorDependencies]),
test: define(null, ["es.regexp.test", "es.regexp.exec"]),
toArray: define(null, ["esnext.async-iterator.to-array", ...AsyncIteratorDependencies, "esnext.iterator.to-array", ...IteratorDependencies]),
toAsync: define(null, ["esnext.iterator.to-async", ...IteratorDependencies, ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods]),
toExponential: define(null, ["es.number.to-exponential"]),
toFixed: define(null, ["es.number.to-fixed"]),
toGMTString: define(null, ["es.date.to-gmt-string"]),
toISOString: define(null, ["es.date.to-iso-string"]),
toJSON: define(null, ["es.date.to-json", "web.url.to-json"]),
toPrecision: define(null, ["es.number.to-precision"]),
toReversed: define("instance/to-reversed", ["es.array.to-reversed"]),
toSorted: define("instance/to-sorted", ["es.array.to-sorted", "es.array.sort"]),
toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]),
toString: define(null, ["es.object.to-string", "es.error.to-string", "es.date.to-string", "es.regexp.to-string"]),
toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]),
trim: define("instance/trim", ["es.string.trim"]),
trimEnd: define("instance/trim-end", ["es.string.trim-end"]),
trimLeft: define("instance/trim-left", ["es.string.trim-start"]),
trimRight: define("instance/trim-right", ["es.string.trim-end"]),
trimStart: define("instance/trim-start", ["es.string.trim-start"]),
uniqueBy: define("instance/unique-by", ["esnext.array.unique-by", "es.map"]),
unshift: define("instance/unshift", ["es.array.unshift"]),
unThis: define("instance/un-this", ["esnext.function.un-this"]),
values: define("instance/values", ArrayNatureIteratorsWithTag),
with: define("instance/with", ["es.array.with"]),
__defineGetter__: define(null, ["es.object.define-getter"]),
__defineSetter__: define(null, ["es.object.define-setter"]),
__lookupGetter__: define(null, ["es.object.lookup-getter"]),
__lookupSetter__: define(null, ["es.object.lookup-setter"]),
["__proto__"]: define(null, ["es.object.proto"])
};
exports.InstanceProperties = InstanceProperties;

View file

@ -0,0 +1,271 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _data = _interopRequireDefault(require("../core-js-compat/data.js"));
var _shippedProposals = _interopRequireDefault(require("./shipped-proposals"));
var _getModulesListForTargetVersion = _interopRequireDefault(require("../core-js-compat/get-modules-list-for-target-version.js"));
var _builtInDefinitions = require("./built-in-definitions");
var _usageFilters = _interopRequireDefault(require("./usage-filters"));
var _babel = _interopRequireWildcard(require("@babel/core"));
var _utils = require("./utils");
var _helperDefinePolyfillProvider = _interopRequireDefault(require("@babel/helper-define-polyfill-provider"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
const {
types: t
} = _babel.default || _babel;
const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility";
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
const uniqueObjects = ["array", "string", "iterator", "async-iterator", "dom-collections"].map(v => new RegExp(`[a-z]*\\.${v}\\..*`));
const esnextFallback = (name, cb) => {
if (cb(name)) return true;
if (!name.startsWith("es.")) return false;
const fallback = `esnext.${name.slice(3)}`;
if (!_data.default[fallback]) return false;
return cb(fallback);
};
var _default = (0, _helperDefinePolyfillProvider.default)(function ({
getUtils,
method,
shouldInjectPolyfill,
createMetaResolver,
debug,
babel
}, {
version = 3,
proposals,
shippedProposals,
[presetEnvCompat]: {
noRuntimeName = false
} = {},
[runtimeCompat]: {
useBabelRuntime = false,
ext = ".js"
} = {}
}) {
const isWebpack = babel.caller(caller => (caller == null ? void 0 : caller.name) === "babel-loader");
const resolve = createMetaResolver({
global: _builtInDefinitions.BuiltIns,
static: _builtInDefinitions.StaticProperties,
instance: _builtInDefinitions.InstanceProperties
});
const available = new Set((0, _getModulesListForTargetVersion.default)(version));
function getCoreJSPureBase(useProposalBase) {
return useBabelRuntime ? useProposalBase ? `${_utils.BABEL_RUNTIME}/core-js` : `${_utils.BABEL_RUNTIME}/core-js-stable` : useProposalBase ? "core-js-pure/features" : "core-js-pure/stable";
}
function maybeInjectGlobalImpl(name, utils) {
if (shouldInjectPolyfill(name)) {
debug(name);
utils.injectGlobalImport((0, _utils.coreJSModule)(name));
return true;
}
return false;
}
function maybeInjectGlobal(names, utils, fallback = true) {
for (const name of names) {
if (fallback) {
esnextFallback(name, name => maybeInjectGlobalImpl(name, utils));
} else {
maybeInjectGlobalImpl(name, utils);
}
}
}
function maybeInjectPure(desc, hint, utils, object) {
if (desc.pure && !(object && desc.exclude && desc.exclude.includes(object)) && esnextFallback(desc.name, shouldInjectPolyfill)) {
const {
name
} = desc;
let useProposalBase = false;
if (proposals || shippedProposals && name.startsWith("esnext.")) {
useProposalBase = true;
} else if (name.startsWith("es.") && !available.has(name)) {
useProposalBase = true;
}
const coreJSPureBase = getCoreJSPureBase(useProposalBase);
return utils.injectDefaultImport(`${coreJSPureBase}/${desc.pure}${ext}`, hint);
}
}
function isFeatureStable(name) {
if (name.startsWith("esnext.")) {
const esName = `es.${name.slice(7)}`;
// If its imaginative esName is not in latest compat data, it means
// the proposal is not stage 4
return esName in _data.default;
}
return true;
}
return {
name: "corejs3",
runtimeName: noRuntimeName ? null : _utils.BABEL_RUNTIME,
polyfills: _data.default,
filterPolyfills(name) {
if (!available.has(name)) return false;
if (proposals || method === "entry-global") return true;
if (shippedProposals && _shippedProposals.default.has(name)) {
return true;
}
return isFeatureStable(name);
},
entryGlobal(meta, utils, path) {
if (meta.kind !== "import") return;
const modules = (0, _utils.isCoreJSSource)(meta.source);
if (!modules) return;
if (modules.length === 1 && meta.source === (0, _utils.coreJSModule)(modules[0]) && shouldInjectPolyfill(modules[0])) {
// Avoid infinite loop: do not replace imports with a new copy of
// themselves.
debug(null);
return;
}
const modulesSet = new Set(modules);
const filteredModules = modules.filter(module => {
if (!module.startsWith("esnext.")) return true;
const stable = module.replace("esnext.", "es.");
if (modulesSet.has(stable) && shouldInjectPolyfill(stable)) {
return false;
}
return true;
});
maybeInjectGlobal(filteredModules, utils, false);
path.remove();
},
usageGlobal(meta, utils, path) {
const resolved = resolve(meta);
if (!resolved) return;
if ((0, _usageFilters.default)(resolved.desc, path)) return;
let deps = resolved.desc.global;
if (resolved.kind !== "global" && "object" in meta && meta.object && meta.placement === "prototype") {
const low = meta.object.toLowerCase();
deps = deps.filter(m => uniqueObjects.some(v => v.test(m)) ? m.includes(low) : true);
}
maybeInjectGlobal(deps, utils);
},
usagePure(meta, utils, path) {
if (meta.kind === "in") {
if (meta.key === "Symbol.iterator") {
path.replaceWith(t.callExpression(utils.injectDefaultImport((0, _utils.coreJSPureHelper)("is-iterable", useBabelRuntime, ext), "isIterable"), [path.node.right] // meta.kind === "in" narrows this
));
}
return;
}
if (path.parentPath.isUnaryExpression({
operator: "delete"
})) return;
if (meta.kind === "property") {
// We can't compile destructuring and updateExpression.
if (!path.isMemberExpression()) return;
if (!path.isReferenced()) return;
if (path.parentPath.isUpdateExpression()) return;
if (t.isSuper(path.node.object)) {
return;
}
if (meta.key === "Symbol.iterator") {
if (!shouldInjectPolyfill("es.symbol.iterator")) return;
const {
parent,
node
} = path;
if (t.isCallExpression(parent, {
callee: node
})) {
if (parent.arguments.length === 0) {
path.parentPath.replaceWith(t.callExpression(utils.injectDefaultImport((0, _utils.coreJSPureHelper)("get-iterator", useBabelRuntime, ext), "getIterator"), [node.object]));
path.skip();
} else {
(0, _utils.callMethod)(path, utils.injectDefaultImport((0, _utils.coreJSPureHelper)("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"));
}
} else {
path.replaceWith(t.callExpression(utils.injectDefaultImport((0, _utils.coreJSPureHelper)("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"), [path.node.object]));
}
return;
}
}
let resolved = resolve(meta);
if (!resolved) return;
if ((0, _usageFilters.default)(resolved.desc, path)) return;
if (useBabelRuntime && resolved.desc.pure && resolved.desc.pure.slice(-6) === "/index") {
// Remove /index, since it doesn't exist in @babel/runtime-corejs3s
resolved = _extends({}, resolved, {
desc: _extends({}, resolved.desc, {
pure: resolved.desc.pure.slice(0, -6)
})
});
}
if (resolved.kind === "global") {
const id = maybeInjectPure(resolved.desc, resolved.name, utils);
if (id) path.replaceWith(id);
} else if (resolved.kind === "static") {
const id = maybeInjectPure(resolved.desc, resolved.name, utils,
// @ts-expect-error
meta.object);
if (id) path.replaceWith(id);
} else if (resolved.kind === "instance") {
const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
// @ts-expect-error
meta.object);
if (!id) return;
const {
node
} = path;
if (t.isCallExpression(path.parent, {
callee: node
})) {
(0, _utils.callMethod)(path, id);
} else {
path.replaceWith(t.callExpression(id, [node.object]));
}
}
},
visitor: method === "usage-global" && {
// import("foo")
CallExpression(path) {
if (path.get("callee").isImport()) {
const utils = getUtils(path);
if (isWebpack) {
// Webpack uses Promise.all to handle dynamic import.
maybeInjectGlobal(_builtInDefinitions.PromiseDependenciesWithIterators, utils);
} else {
maybeInjectGlobal(_builtInDefinitions.PromiseDependencies, utils);
}
}
},
// (async function () { }).finally(...)
Function(path) {
if (path.node.async) {
maybeInjectGlobal(_builtInDefinitions.PromiseDependencies, getUtils(path));
}
},
// for-of, [a, b] = c
"ForOfStatement|ArrayPattern"(path) {
maybeInjectGlobal(_builtInDefinitions.CommonIterators, getUtils(path));
},
// [...spread]
SpreadElement(path) {
if (!path.parentPath.isObjectExpression()) {
maybeInjectGlobal(_builtInDefinitions.CommonIterators, getUtils(path));
}
},
// yield*
YieldExpression(path) {
if (path.node.delegate) {
maybeInjectGlobal(_builtInDefinitions.CommonIterators, getUtils(path));
}
},
// Decorators metadata
Class(path) {
var _path$node$decorators;
const hasDecorators = ((_path$node$decorators = path.node.decorators) == null ? void 0 : _path$node$decorators.length) || path.node.body.body.some(el => {
var _decorators;
return (_decorators = el.decorators) == null ? void 0 : _decorators.length;
});
if (hasDecorators) {
maybeInjectGlobal(_builtInDefinitions.DecoratorMetadataDependencies, getUtils(path));
}
}
}
};
});
exports.default = _default;

View file

@ -0,0 +1,7 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.mjs
var _default = new Set(["esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.array-buffer.detached", "esnext.array-buffer.transfer", "esnext.array-buffer.transfer-to-fixed-length", "esnext.iterator.constructor", "esnext.iterator.drop", "esnext.iterator.every", "esnext.iterator.filter", "esnext.iterator.find", "esnext.iterator.flat-map", "esnext.iterator.for-each", "esnext.iterator.from", "esnext.iterator.map", "esnext.iterator.reduce", "esnext.iterator.some", "esnext.iterator.take", "esnext.iterator.to-array", "esnext.json.is-raw-json", "esnext.json.parse", "esnext.json.raw-json", "esnext.map.group-by", "esnext.object.group-by", "esnext.promise.with-resolvers", "esnext.set.difference.v2", "esnext.set.intersection.v2", "esnext.set.is-disjoint-from.v2", "esnext.set.is-subset-of.v2", "esnext.set.is-superset-of.v2", "esnext.set.symmetric-difference.v2", "esnext.set.union.v2", "esnext.symbol.async-dispose", "esnext.symbol.dispose"]);
exports.default = _default;

View file

@ -0,0 +1,27 @@
"use strict";
exports.__esModule = true;
exports.default = canSkipPolyfill;
var _babel = _interopRequireWildcard(require("@babel/core"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
types: t
} = _babel.default || _babel;
function canSkipPolyfill(desc, path) {
const {
node,
parent
} = path;
switch (desc.name) {
case "es.string.split":
{
if (!t.isCallExpression(parent, {
callee: node
})) return false;
if (parent.arguments.length < 1) return true;
const splitter = parent.arguments[0];
return t.isStringLiteral(splitter) || t.isTemplateLiteral(splitter);
}
}
}

View file

@ -0,0 +1,45 @@
"use strict";
exports.__esModule = true;
exports.BABEL_RUNTIME = void 0;
exports.callMethod = callMethod;
exports.coreJSModule = coreJSModule;
exports.coreJSPureHelper = coreJSPureHelper;
exports.isCoreJSSource = isCoreJSSource;
var _babel = _interopRequireWildcard(require("@babel/core"));
var _entries = _interopRequireDefault(require("../core-js-compat/entries.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
types: t
} = _babel.default || _babel;
const BABEL_RUNTIME = "@babel/runtime-corejs3";
exports.BABEL_RUNTIME = BABEL_RUNTIME;
function callMethod(path, id) {
const {
object
} = path.node;
let context1, context2;
if (t.isIdentifier(object)) {
context1 = object;
context2 = t.cloneNode(object);
} else {
context1 = path.scope.generateDeclaredUidIdentifier("context");
context2 = t.assignmentExpression("=", t.cloneNode(context1), object);
}
path.replaceWith(t.memberExpression(t.callExpression(id, [context2]), t.identifier("call")));
path.parentPath.unshiftContainer("arguments", context1);
}
function isCoreJSSource(source) {
if (typeof source === "string") {
source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
}
return Object.prototype.hasOwnProperty.call(_entries.default, source) && _entries.default[source];
}
function coreJSModule(name) {
return `core-js/modules/${name}.js`;
}
function coreJSPureHelper(name, useBabelRuntime, ext) {
return useBabelRuntime ? `${BABEL_RUNTIME}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
}

View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Nicolò Ribaudo and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,15 @@
# @babel/helper-define-polyfill-provider
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-define-polyfill-provider
```
or using yarn:
```sh
yarn add @babel/helper-define-polyfill-provider --dev
```

View file

@ -0,0 +1,747 @@
import { declare } from '@babel/helper-plugin-utils';
import _getTargets, { prettifyTargets, getInclusionReasons, isRequired } from '@babel/helper-compilation-targets';
import * as _babel from '@babel/core';
const {
types: t$1,
template: template
} = _babel.default || _babel;
function intersection(a, b) {
const result = new Set();
a.forEach(v => b.has(v) && result.add(v));
return result;
}
function has$1(object, key) {
return Object.prototype.hasOwnProperty.call(object, key);
}
function getType(target) {
return Object.prototype.toString.call(target).slice(8, -1);
}
function resolveId(path) {
if (path.isIdentifier() && !path.scope.hasBinding(path.node.name, /* noGlobals */true)) {
return path.node.name;
}
if (path.isPure()) {
const {
deopt
} = path.evaluate();
if (deopt && deopt.isIdentifier()) {
return deopt.node.name;
}
}
}
function resolveKey(path, computed = false) {
const {
scope
} = path;
if (path.isStringLiteral()) return path.node.value;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || path.parent.computed)) {
return path.node.name;
}
if (computed && path.isMemberExpression() && path.get("object").isIdentifier({
name: "Symbol"
}) && !scope.hasBinding("Symbol", /* noGlobals */true)) {
const sym = resolveKey(path.get("property"), path.node.computed);
if (sym) return "Symbol." + sym;
}
if (isIdentifier ? scope.hasBinding(path.node.name, /* noGlobals */true) : path.isPure()) {
const {
value
} = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(obj) {
if (obj.isMemberExpression() && obj.get("property").isIdentifier({
name: "prototype"
})) {
const id = resolveId(obj.get("object"));
if (id) {
return {
id,
placement: "prototype"
};
}
return {
id: null,
placement: null
};
}
const id = resolveId(obj);
if (id) {
return {
id,
placement: "static"
};
}
if (obj.isRegExpLiteral()) {
return {
id: "RegExp",
placement: "prototype"
};
} else if (obj.isFunction()) {
return {
id: "Function",
placement: "prototype"
};
} else if (obj.isPure()) {
const {
value
} = obj.evaluate();
if (value !== undefined) {
return {
id: getType(value),
placement: "prototype"
};
}
}
return {
id: null,
placement: null
};
}
function getImportSource({
node
}) {
if (node.specifiers.length === 0) return node.source.value;
}
function getRequireSource({
node
}) {
if (!t$1.isExpressionStatement(node)) return;
const {
expression
} = node;
if (t$1.isCallExpression(expression) && t$1.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t$1.isStringLiteral(expression.arguments[0])) {
return expression.arguments[0].value;
}
}
function hoist(node) {
// @ts-expect-error
node._blockHoist = 3;
return node;
}
function createUtilsGetter(cache) {
return path => {
const prog = path.findParent(p => p.isProgram());
return {
injectGlobalImport(url) {
cache.storeAnonymous(prog, url, (isScript, source) => {
return isScript ? template.statement.ast`require(${source})` : t$1.importDeclaration([], source);
});
},
injectNamedImport(url, name, hint = name) {
return cache.storeNamed(prog, url, name, (isScript, source, name) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`
var ${id} = require(${source}).${name}
`) : t$1.importDeclaration([t$1.importSpecifier(id, name)], source),
name: id.name
};
});
},
injectDefaultImport(url, hint = url) {
return cache.storeNamed(prog, url, "default", (isScript, source) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`var ${id} = require(${source})`) : t$1.importDeclaration([t$1.importDefaultSpecifier(id)], source),
name: id.name
};
});
}
};
};
}
const {
types: t
} = _babel.default || _babel;
class ImportsCache {
constructor(resolver) {
this._imports = new WeakMap();
this._anonymousImports = new WeakMap();
this._lastImports = new WeakMap();
this._resolver = resolver;
}
storeAnonymous(programPath, url,
// eslint-disable-next-line no-undef
getVal) {
const key = this._normalizeKey(programPath, url);
const imports = this._ensure(this._anonymousImports, programPath, Set);
if (imports.has(key)) return;
const node = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)));
imports.add(key);
this._injectImport(programPath, node);
}
storeNamed(programPath, url, name, getVal) {
const key = this._normalizeKey(programPath, url, name);
const imports = this._ensure(this._imports, programPath, Map);
if (!imports.has(key)) {
const {
node,
name: id
} = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)), t.identifier(name));
imports.set(key, id);
this._injectImport(programPath, node);
}
return t.identifier(imports.get(key));
}
_injectImport(programPath, node) {
const lastImport = this._lastImports.get(programPath);
let newNodes;
if (lastImport && lastImport.node &&
// Sometimes the AST is modified and the "last import"
// we have has been replaced
lastImport.parent === programPath.node && lastImport.container === programPath.node.body) {
newNodes = lastImport.insertAfter(node);
} else {
newNodes = programPath.unshiftContainer("body", node);
}
const newNode = newNodes[newNodes.length - 1];
this._lastImports.set(programPath, newNode);
/*
let lastImport;
programPath.get("body").forEach(path => {
if (path.isImportDeclaration()) lastImport = path;
if (
path.isExpressionStatement() &&
isRequireCall(path.get("expression"))
) {
lastImport = path;
}
if (
path.isVariableDeclaration() &&
path.get("declarations").length === 1 &&
(isRequireCall(path.get("declarations.0.init")) ||
(path.get("declarations.0.init").isMemberExpression() &&
isRequireCall(path.get("declarations.0.init.object"))))
) {
lastImport = path;
}
});*/
}
_ensure(map, programPath, Collection) {
let collection = map.get(programPath);
if (!collection) {
collection = new Collection();
map.set(programPath, collection);
}
return collection;
}
_normalizeKey(programPath, url, name = "") {
const {
sourceType
} = programPath.node;
// If we rely on the imported binding (the "name" parameter), we also need to cache
// based on the sourceType. This is because the module transforms change the names
// of the import variables.
return `${name && sourceType}::${url}::${name}`;
}
}
const presetEnvSilentDebugHeader = "#__secret_key__@babel/preset-env__don't_log_debug_header_and_resolved_targets";
function stringifyTargetsMultiline(targets) {
return JSON.stringify(prettifyTargets(targets), null, 2);
}
function patternToRegExp(pattern) {
if (pattern instanceof RegExp) return pattern;
try {
return new RegExp(`^${pattern}$`);
} catch {
return null;
}
}
function buildUnusedError(label, unused) {
if (!unused.length) return "";
return ` - The following "${label}" patterns didn't match any polyfill:\n` + unused.map(original => ` ${String(original)}\n`).join("");
}
function buldDuplicatesError(duplicates) {
if (!duplicates.size) return "";
return ` - The following polyfills were matched both by "include" and "exclude" patterns:\n` + Array.from(duplicates, name => ` ${name}\n`).join("");
}
function validateIncludeExclude(provider, polyfills, includePatterns, excludePatterns) {
let current;
const filter = pattern => {
const regexp = patternToRegExp(pattern);
if (!regexp) return false;
let matched = false;
for (const polyfill of polyfills) {
if (regexp.test(polyfill)) {
matched = true;
current.add(polyfill);
}
}
return !matched;
};
// prettier-ignore
const include = current = new Set();
const unusedInclude = Array.from(includePatterns).filter(filter);
// prettier-ignore
const exclude = current = new Set();
const unusedExclude = Array.from(excludePatterns).filter(filter);
const duplicates = intersection(include, exclude);
if (duplicates.size > 0 || unusedInclude.length > 0 || unusedExclude.length > 0) {
throw new Error(`Error while validating the "${provider}" provider options:\n` + buildUnusedError("include", unusedInclude) + buildUnusedError("exclude", unusedExclude) + buldDuplicatesError(duplicates));
}
return {
include,
exclude
};
}
function applyMissingDependenciesDefaults(options, babelApi) {
const {
missingDependencies = {}
} = options;
if (missingDependencies === false) return false;
const caller = babelApi.caller(caller => caller == null ? void 0 : caller.name);
const {
log = "deferred",
inject = caller === "rollup-plugin-babel" ? "throw" : "import",
all = false
} = missingDependencies;
return {
log,
inject,
all
};
}
var usage = (callProvider => {
function property(object, key, placement, path) {
return callProvider({
kind: "property",
object,
key,
placement
}, path);
}
return {
// Symbol(), new Promise
ReferencedIdentifier(path) {
const {
node: {
name
},
scope
} = path;
if (scope.getBindingIdentifier(name)) return;
callProvider({
kind: "global",
name
}, path);
},
MemberExpression(path) {
const key = resolveKey(path.get("property"), path.node.computed);
if (!key || key === "prototype") return;
const object = path.get("object");
if (object.isIdentifier()) {
const binding = object.scope.getBinding(object.node.name);
if (binding && binding.path.isImportNamespaceSpecifier()) return;
}
const source = resolveSource(object);
return property(source.id, key, source.placement, path);
},
ObjectPattern(path) {
const {
parentPath,
parent
} = path;
let obj;
// const { keys, values } = Object
if (parentPath.isVariableDeclarator()) {
obj = parentPath.get("init");
// ({ keys, values } = Object)
} else if (parentPath.isAssignmentExpression()) {
obj = parentPath.get("right");
// !function ({ keys, values }) {...} (Object)
// resolution does not work after properties transform :-(
} else if (parentPath.isFunction()) {
const grand = parentPath.parentPath;
if (grand.isCallExpression() || grand.isNewExpression()) {
if (grand.node.callee === parent) {
obj = grand.get("arguments")[path.key];
}
}
}
let id = null;
let placement = null;
if (obj) ({
id,
placement
} = resolveSource(obj));
for (const prop of path.get("properties")) {
if (prop.isObjectProperty()) {
const key = resolveKey(prop.get("key"));
if (key) property(id, key, placement, prop);
}
}
},
BinaryExpression(path) {
if (path.node.operator !== "in") return;
const source = resolveSource(path.get("right"));
const key = resolveKey(path.get("left"), true);
if (!key) return;
callProvider({
kind: "in",
object: source.id,
key,
placement: source.placement
}, path);
}
};
});
var entry = (callProvider => ({
ImportDeclaration(path) {
const source = getImportSource(path);
if (!source) return;
callProvider({
kind: "import",
source
}, path);
},
Program(path) {
path.get("body").forEach(bodyPath => {
const source = getRequireSource(bodyPath);
if (!source) return;
callProvider({
kind: "import",
source
}, bodyPath);
});
}
}));
function resolve(dirname, moduleName, absoluteImports) {
if (absoluteImports === false) return moduleName;
throw new Error(`"absoluteImports" is not supported in bundles prepared for the browser.`);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function has(basedir, name) {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function logMissing(missingDeps) {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function laterLogMissing(missingDeps) {}
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
function createMetaResolver(polyfills) {
const {
static: staticP,
instance: instanceP,
global: globalP
} = polyfills;
return meta => {
if (meta.kind === "global" && globalP && has$1(globalP, meta.name)) {
return {
kind: "global",
desc: globalP[meta.name],
name: meta.name
};
}
if (meta.kind === "property" || meta.kind === "in") {
const {
placement,
object,
key
} = meta;
if (object && placement === "static") {
if (globalP && PossibleGlobalObjects.has(object) && has$1(globalP, key)) {
return {
kind: "global",
desc: globalP[key],
name: key
};
}
if (staticP && has$1(staticP, object) && has$1(staticP[object], key)) {
return {
kind: "static",
desc: staticP[object][key],
name: `${object}$${key}`
};
}
}
if (instanceP && has$1(instanceP, key)) {
return {
kind: "instance",
desc: instanceP[key],
name: `${key}`
};
}
}
};
}
const getTargets = _getTargets.default || _getTargets;
function resolveOptions(options, babelApi) {
const {
method,
targets: targetsOption,
ignoreBrowserslistConfig,
configPath,
debug,
shouldInjectPolyfill,
absoluteImports,
...providerOptions
} = options;
if (isEmpty(options)) {
throw new Error(`\
This plugin requires options, for example:
{
"plugins": [
["<plugin name>", { method: "usage-pure" }]
]
}
See more options at https://github.com/babel/babel-polyfills/blob/main/docs/usage.md`);
}
let methodName;
if (method === "usage-global") methodName = "usageGlobal";else if (method === "entry-global") methodName = "entryGlobal";else if (method === "usage-pure") methodName = "usagePure";else if (typeof method !== "string") {
throw new Error(".method must be a string");
} else {
throw new Error(`.method must be one of "entry-global", "usage-global"` + ` or "usage-pure" (received ${JSON.stringify(method)})`);
}
if (typeof shouldInjectPolyfill === "function") {
if (options.include || options.exclude) {
throw new Error(`.include and .exclude are not supported when using the` + ` .shouldInjectPolyfill function.`);
}
} else if (shouldInjectPolyfill != null) {
throw new Error(`.shouldInjectPolyfill must be a function, or undefined` + ` (received ${JSON.stringify(shouldInjectPolyfill)})`);
}
if (absoluteImports != null && typeof absoluteImports !== "boolean" && typeof absoluteImports !== "string") {
throw new Error(`.absoluteImports must be a boolean, a string, or undefined` + ` (received ${JSON.stringify(absoluteImports)})`);
}
let targets;
if (
// If any browserslist-related option is specified, fallback to the old
// behavior of not using the targets specified in the top-level options.
targetsOption || configPath || ignoreBrowserslistConfig) {
const targetsObj = typeof targetsOption === "string" || Array.isArray(targetsOption) ? {
browsers: targetsOption
} : targetsOption;
targets = getTargets(targetsObj, {
ignoreBrowserslistConfig,
configPath
});
} else {
targets = babelApi.targets();
}
return {
method,
methodName,
targets,
absoluteImports: absoluteImports != null ? absoluteImports : false,
shouldInjectPolyfill,
debug: !!debug,
providerOptions: providerOptions
};
}
function instantiateProvider(factory, options, missingDependencies, dirname, debugLog, babelApi) {
const {
method,
methodName,
targets,
debug,
shouldInjectPolyfill,
providerOptions,
absoluteImports
} = resolveOptions(options, babelApi);
const getUtils = createUtilsGetter(new ImportsCache(moduleName => resolve(dirname, moduleName, absoluteImports)));
// eslint-disable-next-line prefer-const
let include, exclude;
let polyfillsSupport;
let polyfillsNames;
let filterPolyfills;
const depsCache = new Map();
const api = {
babel: babelApi,
getUtils,
method: options.method,
targets,
createMetaResolver,
shouldInjectPolyfill(name) {
if (polyfillsNames === undefined) {
throw new Error(`Internal error in the ${factory.name} provider: ` + `shouldInjectPolyfill() can't be called during initialization.`);
}
if (!polyfillsNames.has(name)) {
console.warn(`Internal error in the ${providerName} provider: ` + `unknown polyfill "${name}".`);
}
if (filterPolyfills && !filterPolyfills(name)) return false;
let shouldInject = isRequired(name, targets, {
compatData: polyfillsSupport,
includes: include,
excludes: exclude
});
if (shouldInjectPolyfill) {
shouldInject = shouldInjectPolyfill(name, shouldInject);
if (typeof shouldInject !== "boolean") {
throw new Error(`.shouldInjectPolyfill must return a boolean.`);
}
}
return shouldInject;
},
debug(name) {
var _debugLog, _debugLog$polyfillsSu;
debugLog().found = true;
if (!debug || !name) return;
if (debugLog().polyfills.has(providerName)) return;
debugLog().polyfills.add(name);
(_debugLog$polyfillsSu = (_debugLog = debugLog()).polyfillsSupport) != null ? _debugLog$polyfillsSu : _debugLog.polyfillsSupport = polyfillsSupport;
},
assertDependency(name, version = "*") {
if (missingDependencies === false) return;
if (absoluteImports) {
// If absoluteImports is not false, we will try resolving
// the dependency and throw if it's not possible. We can
// skip the check here.
return;
}
const dep = version === "*" ? name : `${name}@^${version}`;
const found = missingDependencies.all ? false : mapGetOr(depsCache, `${name} :: ${dirname}`, () => has());
if (!found) {
debugLog().missingDeps.add(dep);
}
}
};
const provider = factory(api, providerOptions, dirname);
const providerName = provider.name || factory.name;
if (typeof provider[methodName] !== "function") {
throw new Error(`The "${providerName}" provider doesn't support the "${method}" polyfilling method.`);
}
if (Array.isArray(provider.polyfills)) {
polyfillsNames = new Set(provider.polyfills);
filterPolyfills = provider.filterPolyfills;
} else if (provider.polyfills) {
polyfillsNames = new Set(Object.keys(provider.polyfills));
polyfillsSupport = provider.polyfills;
filterPolyfills = provider.filterPolyfills;
} else {
polyfillsNames = new Set();
}
({
include,
exclude
} = validateIncludeExclude(providerName, polyfillsNames, providerOptions.include || [], providerOptions.exclude || []));
return {
debug,
method,
targets,
provider,
providerName,
callProvider(payload, path) {
const utils = getUtils(path);
provider[methodName](payload, utils, path);
}
};
}
function definePolyfillProvider(factory) {
return declare((babelApi, options, dirname) => {
babelApi.assertVersion("^7.0.0 || ^8.0.0-alpha.0");
const {
traverse
} = babelApi;
let debugLog;
const missingDependencies = applyMissingDependenciesDefaults(options, babelApi);
const {
debug,
method,
targets,
provider,
providerName,
callProvider
} = instantiateProvider(factory, options, missingDependencies, dirname, () => debugLog, babelApi);
const createVisitor = method === "entry-global" ? entry : usage;
const visitor = provider.visitor ? traverse.visitors.merge([createVisitor(callProvider), provider.visitor]) : createVisitor(callProvider);
if (debug && debug !== presetEnvSilentDebugHeader) {
console.log(`${providerName}: \`DEBUG\` option`);
console.log(`\nUsing targets: ${stringifyTargetsMultiline(targets)}`);
console.log(`\nUsing polyfills with \`${method}\` method:`);
}
const {
runtimeName
} = provider;
return {
name: "inject-polyfills",
visitor,
pre(file) {
var _provider$pre;
if (runtimeName) {
if (file.get("runtimeHelpersModuleName") && file.get("runtimeHelpersModuleName") !== runtimeName) {
console.warn(`Two different polyfill providers` + ` (${file.get("runtimeHelpersModuleProvider")}` + ` and ${providerName}) are trying to define two` + ` conflicting @babel/runtime alternatives:` + ` ${file.get("runtimeHelpersModuleName")} and ${runtimeName}.` + ` The second one will be ignored.`);
} else {
file.set("runtimeHelpersModuleName", runtimeName);
file.set("runtimeHelpersModuleProvider", providerName);
}
}
debugLog = {
polyfills: new Set(),
polyfillsSupport: undefined,
found: false,
providers: new Set(),
missingDeps: new Set()
};
(_provider$pre = provider.pre) == null ? void 0 : _provider$pre.apply(this, arguments);
},
post() {
var _provider$post;
(_provider$post = provider.post) == null ? void 0 : _provider$post.apply(this, arguments);
if (missingDependencies !== false) {
if (missingDependencies.log === "per-file") {
logMissing(debugLog.missingDeps);
} else {
laterLogMissing(debugLog.missingDeps);
}
}
if (!debug) return;
if (this.filename) console.log(`\n[${this.filename}]`);
if (debugLog.polyfills.size === 0) {
console.log(method === "entry-global" ? debugLog.found ? `Based on your targets, the ${providerName} polyfill did not add any polyfill.` : `The entry point for the ${providerName} polyfill has not been found.` : `Based on your code and targets, the ${providerName} polyfill did not add any polyfill.`);
return;
}
if (method === "entry-global") {
console.log(`The ${providerName} polyfill entry has been replaced with ` + `the following polyfills:`);
} else {
console.log(`The ${providerName} polyfill added the following polyfills:`);
}
for (const name of debugLog.polyfills) {
var _debugLog$polyfillsSu2;
if ((_debugLog$polyfillsSu2 = debugLog.polyfillsSupport) != null && _debugLog$polyfillsSu2[name]) {
const filteredTargets = getInclusionReasons(name, targets, debugLog.polyfillsSupport);
const formattedTargets = JSON.stringify(filteredTargets).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
console.log(` ${name} ${formattedTargets}`);
} else {
console.log(` ${name}`);
}
}
}
};
});
}
function mapGetOr(map, key, getDefault) {
let val = map.get(key);
if (val === undefined) {
val = getDefault();
map.set(key, val);
}
return val;
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
export default definePolyfillProvider;
//# sourceMappingURL=index.browser.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,791 @@
import { declare } from '@babel/helper-plugin-utils';
import _getTargets, { prettifyTargets, getInclusionReasons, isRequired } from '@babel/helper-compilation-targets';
import * as _babel from '@babel/core';
import path from 'path';
import debounce from 'lodash.debounce';
import requireResolve from 'resolve';
import { createRequire } from 'module';
const {
types: t$1,
template: template
} = _babel.default || _babel;
function intersection(a, b) {
const result = new Set();
a.forEach(v => b.has(v) && result.add(v));
return result;
}
function has$1(object, key) {
return Object.prototype.hasOwnProperty.call(object, key);
}
function getType(target) {
return Object.prototype.toString.call(target).slice(8, -1);
}
function resolveId(path) {
if (path.isIdentifier() && !path.scope.hasBinding(path.node.name, /* noGlobals */true)) {
return path.node.name;
}
if (path.isPure()) {
const {
deopt
} = path.evaluate();
if (deopt && deopt.isIdentifier()) {
return deopt.node.name;
}
}
}
function resolveKey(path, computed = false) {
const {
scope
} = path;
if (path.isStringLiteral()) return path.node.value;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || path.parent.computed)) {
return path.node.name;
}
if (computed && path.isMemberExpression() && path.get("object").isIdentifier({
name: "Symbol"
}) && !scope.hasBinding("Symbol", /* noGlobals */true)) {
const sym = resolveKey(path.get("property"), path.node.computed);
if (sym) return "Symbol." + sym;
}
if (isIdentifier ? scope.hasBinding(path.node.name, /* noGlobals */true) : path.isPure()) {
const {
value
} = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(obj) {
if (obj.isMemberExpression() && obj.get("property").isIdentifier({
name: "prototype"
})) {
const id = resolveId(obj.get("object"));
if (id) {
return {
id,
placement: "prototype"
};
}
return {
id: null,
placement: null
};
}
const id = resolveId(obj);
if (id) {
return {
id,
placement: "static"
};
}
if (obj.isRegExpLiteral()) {
return {
id: "RegExp",
placement: "prototype"
};
} else if (obj.isFunction()) {
return {
id: "Function",
placement: "prototype"
};
} else if (obj.isPure()) {
const {
value
} = obj.evaluate();
if (value !== undefined) {
return {
id: getType(value),
placement: "prototype"
};
}
}
return {
id: null,
placement: null
};
}
function getImportSource({
node
}) {
if (node.specifiers.length === 0) return node.source.value;
}
function getRequireSource({
node
}) {
if (!t$1.isExpressionStatement(node)) return;
const {
expression
} = node;
if (t$1.isCallExpression(expression) && t$1.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t$1.isStringLiteral(expression.arguments[0])) {
return expression.arguments[0].value;
}
}
function hoist(node) {
// @ts-expect-error
node._blockHoist = 3;
return node;
}
function createUtilsGetter(cache) {
return path => {
const prog = path.findParent(p => p.isProgram());
return {
injectGlobalImport(url) {
cache.storeAnonymous(prog, url, (isScript, source) => {
return isScript ? template.statement.ast`require(${source})` : t$1.importDeclaration([], source);
});
},
injectNamedImport(url, name, hint = name) {
return cache.storeNamed(prog, url, name, (isScript, source, name) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`
var ${id} = require(${source}).${name}
`) : t$1.importDeclaration([t$1.importSpecifier(id, name)], source),
name: id.name
};
});
},
injectDefaultImport(url, hint = url) {
return cache.storeNamed(prog, url, "default", (isScript, source) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`var ${id} = require(${source})`) : t$1.importDeclaration([t$1.importDefaultSpecifier(id)], source),
name: id.name
};
});
}
};
};
}
const {
types: t
} = _babel.default || _babel;
class ImportsCache {
constructor(resolver) {
this._imports = new WeakMap();
this._anonymousImports = new WeakMap();
this._lastImports = new WeakMap();
this._resolver = resolver;
}
storeAnonymous(programPath, url,
// eslint-disable-next-line no-undef
getVal) {
const key = this._normalizeKey(programPath, url);
const imports = this._ensure(this._anonymousImports, programPath, Set);
if (imports.has(key)) return;
const node = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)));
imports.add(key);
this._injectImport(programPath, node);
}
storeNamed(programPath, url, name, getVal) {
const key = this._normalizeKey(programPath, url, name);
const imports = this._ensure(this._imports, programPath, Map);
if (!imports.has(key)) {
const {
node,
name: id
} = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)), t.identifier(name));
imports.set(key, id);
this._injectImport(programPath, node);
}
return t.identifier(imports.get(key));
}
_injectImport(programPath, node) {
const lastImport = this._lastImports.get(programPath);
let newNodes;
if (lastImport && lastImport.node &&
// Sometimes the AST is modified and the "last import"
// we have has been replaced
lastImport.parent === programPath.node && lastImport.container === programPath.node.body) {
newNodes = lastImport.insertAfter(node);
} else {
newNodes = programPath.unshiftContainer("body", node);
}
const newNode = newNodes[newNodes.length - 1];
this._lastImports.set(programPath, newNode);
/*
let lastImport;
programPath.get("body").forEach(path => {
if (path.isImportDeclaration()) lastImport = path;
if (
path.isExpressionStatement() &&
isRequireCall(path.get("expression"))
) {
lastImport = path;
}
if (
path.isVariableDeclaration() &&
path.get("declarations").length === 1 &&
(isRequireCall(path.get("declarations.0.init")) ||
(path.get("declarations.0.init").isMemberExpression() &&
isRequireCall(path.get("declarations.0.init.object"))))
) {
lastImport = path;
}
});*/
}
_ensure(map, programPath, Collection) {
let collection = map.get(programPath);
if (!collection) {
collection = new Collection();
map.set(programPath, collection);
}
return collection;
}
_normalizeKey(programPath, url, name = "") {
const {
sourceType
} = programPath.node;
// If we rely on the imported binding (the "name" parameter), we also need to cache
// based on the sourceType. This is because the module transforms change the names
// of the import variables.
return `${name && sourceType}::${url}::${name}`;
}
}
const presetEnvSilentDebugHeader = "#__secret_key__@babel/preset-env__don't_log_debug_header_and_resolved_targets";
function stringifyTargetsMultiline(targets) {
return JSON.stringify(prettifyTargets(targets), null, 2);
}
function patternToRegExp(pattern) {
if (pattern instanceof RegExp) return pattern;
try {
return new RegExp(`^${pattern}$`);
} catch {
return null;
}
}
function buildUnusedError(label, unused) {
if (!unused.length) return "";
return ` - The following "${label}" patterns didn't match any polyfill:\n` + unused.map(original => ` ${String(original)}\n`).join("");
}
function buldDuplicatesError(duplicates) {
if (!duplicates.size) return "";
return ` - The following polyfills were matched both by "include" and "exclude" patterns:\n` + Array.from(duplicates, name => ` ${name}\n`).join("");
}
function validateIncludeExclude(provider, polyfills, includePatterns, excludePatterns) {
let current;
const filter = pattern => {
const regexp = patternToRegExp(pattern);
if (!regexp) return false;
let matched = false;
for (const polyfill of polyfills) {
if (regexp.test(polyfill)) {
matched = true;
current.add(polyfill);
}
}
return !matched;
};
// prettier-ignore
const include = current = new Set();
const unusedInclude = Array.from(includePatterns).filter(filter);
// prettier-ignore
const exclude = current = new Set();
const unusedExclude = Array.from(excludePatterns).filter(filter);
const duplicates = intersection(include, exclude);
if (duplicates.size > 0 || unusedInclude.length > 0 || unusedExclude.length > 0) {
throw new Error(`Error while validating the "${provider}" provider options:\n` + buildUnusedError("include", unusedInclude) + buildUnusedError("exclude", unusedExclude) + buldDuplicatesError(duplicates));
}
return {
include,
exclude
};
}
function applyMissingDependenciesDefaults(options, babelApi) {
const {
missingDependencies = {}
} = options;
if (missingDependencies === false) return false;
const caller = babelApi.caller(caller => caller == null ? void 0 : caller.name);
const {
log = "deferred",
inject = caller === "rollup-plugin-babel" ? "throw" : "import",
all = false
} = missingDependencies;
return {
log,
inject,
all
};
}
var usage = (callProvider => {
function property(object, key, placement, path) {
return callProvider({
kind: "property",
object,
key,
placement
}, path);
}
return {
// Symbol(), new Promise
ReferencedIdentifier(path) {
const {
node: {
name
},
scope
} = path;
if (scope.getBindingIdentifier(name)) return;
callProvider({
kind: "global",
name
}, path);
},
MemberExpression(path) {
const key = resolveKey(path.get("property"), path.node.computed);
if (!key || key === "prototype") return;
const object = path.get("object");
if (object.isIdentifier()) {
const binding = object.scope.getBinding(object.node.name);
if (binding && binding.path.isImportNamespaceSpecifier()) return;
}
const source = resolveSource(object);
return property(source.id, key, source.placement, path);
},
ObjectPattern(path) {
const {
parentPath,
parent
} = path;
let obj;
// const { keys, values } = Object
if (parentPath.isVariableDeclarator()) {
obj = parentPath.get("init");
// ({ keys, values } = Object)
} else if (parentPath.isAssignmentExpression()) {
obj = parentPath.get("right");
// !function ({ keys, values }) {...} (Object)
// resolution does not work after properties transform :-(
} else if (parentPath.isFunction()) {
const grand = parentPath.parentPath;
if (grand.isCallExpression() || grand.isNewExpression()) {
if (grand.node.callee === parent) {
obj = grand.get("arguments")[path.key];
}
}
}
let id = null;
let placement = null;
if (obj) ({
id,
placement
} = resolveSource(obj));
for (const prop of path.get("properties")) {
if (prop.isObjectProperty()) {
const key = resolveKey(prop.get("key"));
if (key) property(id, key, placement, prop);
}
}
},
BinaryExpression(path) {
if (path.node.operator !== "in") return;
const source = resolveSource(path.get("right"));
const key = resolveKey(path.get("left"), true);
if (!key) return;
callProvider({
kind: "in",
object: source.id,
key,
placement: source.placement
}, path);
}
};
});
var entry = (callProvider => ({
ImportDeclaration(path) {
const source = getImportSource(path);
if (!source) return;
callProvider({
kind: "import",
source
}, path);
},
Program(path) {
path.get("body").forEach(bodyPath => {
const source = getRequireSource(bodyPath);
if (!source) return;
callProvider({
kind: "import",
source
}, bodyPath);
});
}
}));
const nativeRequireResolve = parseFloat(process.versions.node) >= 8.9;
const require = createRequire(import /*::(_)*/.meta.url); // eslint-disable-line
function myResolve(name, basedir) {
if (nativeRequireResolve) {
return require.resolve(name, {
paths: [basedir]
}).replace(/\\/g, "/");
} else {
return requireResolve.sync(name, {
basedir
}).replace(/\\/g, "/");
}
}
function resolve(dirname, moduleName, absoluteImports) {
if (absoluteImports === false) return moduleName;
let basedir = dirname;
if (typeof absoluteImports === "string") {
basedir = path.resolve(basedir, absoluteImports);
}
try {
return myResolve(moduleName, basedir);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
code: "BABEL_POLYFILL_NOT_FOUND",
polyfill: moduleName,
dirname
});
}
}
function has(basedir, name) {
try {
myResolve(name, basedir);
return true;
} catch {
return false;
}
}
function logMissing(missingDeps) {
if (missingDeps.size === 0) return;
const deps = Array.from(missingDeps).sort().join(" ");
console.warn("\nSome polyfills have been added but are not present in your dependencies.\n" + "Please run one of the following commands:\n" + `\tnpm install --save ${deps}\n` + `\tyarn add ${deps}\n`);
process.exitCode = 1;
}
let allMissingDeps = new Set();
const laterLogMissingDependencies = debounce(() => {
logMissing(allMissingDeps);
allMissingDeps = new Set();
}, 100);
function laterLogMissing(missingDeps) {
if (missingDeps.size === 0) return;
missingDeps.forEach(name => allMissingDeps.add(name));
laterLogMissingDependencies();
}
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
function createMetaResolver(polyfills) {
const {
static: staticP,
instance: instanceP,
global: globalP
} = polyfills;
return meta => {
if (meta.kind === "global" && globalP && has$1(globalP, meta.name)) {
return {
kind: "global",
desc: globalP[meta.name],
name: meta.name
};
}
if (meta.kind === "property" || meta.kind === "in") {
const {
placement,
object,
key
} = meta;
if (object && placement === "static") {
if (globalP && PossibleGlobalObjects.has(object) && has$1(globalP, key)) {
return {
kind: "global",
desc: globalP[key],
name: key
};
}
if (staticP && has$1(staticP, object) && has$1(staticP[object], key)) {
return {
kind: "static",
desc: staticP[object][key],
name: `${object}$${key}`
};
}
}
if (instanceP && has$1(instanceP, key)) {
return {
kind: "instance",
desc: instanceP[key],
name: `${key}`
};
}
}
};
}
const getTargets = _getTargets.default || _getTargets;
function resolveOptions(options, babelApi) {
const {
method,
targets: targetsOption,
ignoreBrowserslistConfig,
configPath,
debug,
shouldInjectPolyfill,
absoluteImports,
...providerOptions
} = options;
if (isEmpty(options)) {
throw new Error(`\
This plugin requires options, for example:
{
"plugins": [
["<plugin name>", { method: "usage-pure" }]
]
}
See more options at https://github.com/babel/babel-polyfills/blob/main/docs/usage.md`);
}
let methodName;
if (method === "usage-global") methodName = "usageGlobal";else if (method === "entry-global") methodName = "entryGlobal";else if (method === "usage-pure") methodName = "usagePure";else if (typeof method !== "string") {
throw new Error(".method must be a string");
} else {
throw new Error(`.method must be one of "entry-global", "usage-global"` + ` or "usage-pure" (received ${JSON.stringify(method)})`);
}
if (typeof shouldInjectPolyfill === "function") {
if (options.include || options.exclude) {
throw new Error(`.include and .exclude are not supported when using the` + ` .shouldInjectPolyfill function.`);
}
} else if (shouldInjectPolyfill != null) {
throw new Error(`.shouldInjectPolyfill must be a function, or undefined` + ` (received ${JSON.stringify(shouldInjectPolyfill)})`);
}
if (absoluteImports != null && typeof absoluteImports !== "boolean" && typeof absoluteImports !== "string") {
throw new Error(`.absoluteImports must be a boolean, a string, or undefined` + ` (received ${JSON.stringify(absoluteImports)})`);
}
let targets;
if (
// If any browserslist-related option is specified, fallback to the old
// behavior of not using the targets specified in the top-level options.
targetsOption || configPath || ignoreBrowserslistConfig) {
const targetsObj = typeof targetsOption === "string" || Array.isArray(targetsOption) ? {
browsers: targetsOption
} : targetsOption;
targets = getTargets(targetsObj, {
ignoreBrowserslistConfig,
configPath
});
} else {
targets = babelApi.targets();
}
return {
method,
methodName,
targets,
absoluteImports: absoluteImports != null ? absoluteImports : false,
shouldInjectPolyfill,
debug: !!debug,
providerOptions: providerOptions
};
}
function instantiateProvider(factory, options, missingDependencies, dirname, debugLog, babelApi) {
const {
method,
methodName,
targets,
debug,
shouldInjectPolyfill,
providerOptions,
absoluteImports
} = resolveOptions(options, babelApi);
const getUtils = createUtilsGetter(new ImportsCache(moduleName => resolve(dirname, moduleName, absoluteImports)));
// eslint-disable-next-line prefer-const
let include, exclude;
let polyfillsSupport;
let polyfillsNames;
let filterPolyfills;
const depsCache = new Map();
const api = {
babel: babelApi,
getUtils,
method: options.method,
targets,
createMetaResolver,
shouldInjectPolyfill(name) {
if (polyfillsNames === undefined) {
throw new Error(`Internal error in the ${factory.name} provider: ` + `shouldInjectPolyfill() can't be called during initialization.`);
}
if (!polyfillsNames.has(name)) {
console.warn(`Internal error in the ${providerName} provider: ` + `unknown polyfill "${name}".`);
}
if (filterPolyfills && !filterPolyfills(name)) return false;
let shouldInject = isRequired(name, targets, {
compatData: polyfillsSupport,
includes: include,
excludes: exclude
});
if (shouldInjectPolyfill) {
shouldInject = shouldInjectPolyfill(name, shouldInject);
if (typeof shouldInject !== "boolean") {
throw new Error(`.shouldInjectPolyfill must return a boolean.`);
}
}
return shouldInject;
},
debug(name) {
var _debugLog, _debugLog$polyfillsSu;
debugLog().found = true;
if (!debug || !name) return;
if (debugLog().polyfills.has(providerName)) return;
debugLog().polyfills.add(name);
(_debugLog$polyfillsSu = (_debugLog = debugLog()).polyfillsSupport) != null ? _debugLog$polyfillsSu : _debugLog.polyfillsSupport = polyfillsSupport;
},
assertDependency(name, version = "*") {
if (missingDependencies === false) return;
if (absoluteImports) {
// If absoluteImports is not false, we will try resolving
// the dependency and throw if it's not possible. We can
// skip the check here.
return;
}
const dep = version === "*" ? name : `${name}@^${version}`;
const found = missingDependencies.all ? false : mapGetOr(depsCache, `${name} :: ${dirname}`, () => has(dirname, name));
if (!found) {
debugLog().missingDeps.add(dep);
}
}
};
const provider = factory(api, providerOptions, dirname);
const providerName = provider.name || factory.name;
if (typeof provider[methodName] !== "function") {
throw new Error(`The "${providerName}" provider doesn't support the "${method}" polyfilling method.`);
}
if (Array.isArray(provider.polyfills)) {
polyfillsNames = new Set(provider.polyfills);
filterPolyfills = provider.filterPolyfills;
} else if (provider.polyfills) {
polyfillsNames = new Set(Object.keys(provider.polyfills));
polyfillsSupport = provider.polyfills;
filterPolyfills = provider.filterPolyfills;
} else {
polyfillsNames = new Set();
}
({
include,
exclude
} = validateIncludeExclude(providerName, polyfillsNames, providerOptions.include || [], providerOptions.exclude || []));
return {
debug,
method,
targets,
provider,
providerName,
callProvider(payload, path) {
const utils = getUtils(path);
provider[methodName](payload, utils, path);
}
};
}
function definePolyfillProvider(factory) {
return declare((babelApi, options, dirname) => {
babelApi.assertVersion("^7.0.0 || ^8.0.0-alpha.0");
const {
traverse
} = babelApi;
let debugLog;
const missingDependencies = applyMissingDependenciesDefaults(options, babelApi);
const {
debug,
method,
targets,
provider,
providerName,
callProvider
} = instantiateProvider(factory, options, missingDependencies, dirname, () => debugLog, babelApi);
const createVisitor = method === "entry-global" ? entry : usage;
const visitor = provider.visitor ? traverse.visitors.merge([createVisitor(callProvider), provider.visitor]) : createVisitor(callProvider);
if (debug && debug !== presetEnvSilentDebugHeader) {
console.log(`${providerName}: \`DEBUG\` option`);
console.log(`\nUsing targets: ${stringifyTargetsMultiline(targets)}`);
console.log(`\nUsing polyfills with \`${method}\` method:`);
}
const {
runtimeName
} = provider;
return {
name: "inject-polyfills",
visitor,
pre(file) {
var _provider$pre;
if (runtimeName) {
if (file.get("runtimeHelpersModuleName") && file.get("runtimeHelpersModuleName") !== runtimeName) {
console.warn(`Two different polyfill providers` + ` (${file.get("runtimeHelpersModuleProvider")}` + ` and ${providerName}) are trying to define two` + ` conflicting @babel/runtime alternatives:` + ` ${file.get("runtimeHelpersModuleName")} and ${runtimeName}.` + ` The second one will be ignored.`);
} else {
file.set("runtimeHelpersModuleName", runtimeName);
file.set("runtimeHelpersModuleProvider", providerName);
}
}
debugLog = {
polyfills: new Set(),
polyfillsSupport: undefined,
found: false,
providers: new Set(),
missingDeps: new Set()
};
(_provider$pre = provider.pre) == null ? void 0 : _provider$pre.apply(this, arguments);
},
post() {
var _provider$post;
(_provider$post = provider.post) == null ? void 0 : _provider$post.apply(this, arguments);
if (missingDependencies !== false) {
if (missingDependencies.log === "per-file") {
logMissing(debugLog.missingDeps);
} else {
laterLogMissing(debugLog.missingDeps);
}
}
if (!debug) return;
if (this.filename) console.log(`\n[${this.filename}]`);
if (debugLog.polyfills.size === 0) {
console.log(method === "entry-global" ? debugLog.found ? `Based on your targets, the ${providerName} polyfill did not add any polyfill.` : `The entry point for the ${providerName} polyfill has not been found.` : `Based on your code and targets, the ${providerName} polyfill did not add any polyfill.`);
return;
}
if (method === "entry-global") {
console.log(`The ${providerName} polyfill entry has been replaced with ` + `the following polyfills:`);
} else {
console.log(`The ${providerName} polyfill added the following polyfills:`);
}
for (const name of debugLog.polyfills) {
var _debugLog$polyfillsSu2;
if ((_debugLog$polyfillsSu2 = debugLog.polyfillsSupport) != null && _debugLog$polyfillsSu2[name]) {
const filteredTargets = getInclusionReasons(name, targets, debugLog.polyfillsSupport);
const formattedTargets = JSON.stringify(filteredTargets).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
console.log(` ${name} ${formattedTargets}`);
} else {
console.log(` ${name}`);
}
}
}
};
});
}
function mapGetOr(map, key, getDefault) {
let val = map.get(key);
if (val === undefined) {
val = getDefault();
map.set(key, val);
}
return val;
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
export default definePolyfillProvider;
//# sourceMappingURL=index.node.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,22 @@
"use strict";
exports.__esModule = true;
exports.has = has;
exports.laterLogMissing = laterLogMissing;
exports.logMissing = logMissing;
exports.resolve = resolve;
function resolve(dirname, moduleName, absoluteImports) {
if (absoluteImports === false) return moduleName;
throw new Error(`"absoluteImports" is not supported in bundles prepared for the browser.`);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function has(basedir, name) {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function logMissing(missingDeps) {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function laterLogMissing(missingDeps) {}

View file

@ -0,0 +1,15 @@
"use strict";
exports.__esModule = true;
exports.presetEnvSilentDebugHeader = void 0;
exports.stringifyTargets = stringifyTargets;
exports.stringifyTargetsMultiline = stringifyTargetsMultiline;
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
const presetEnvSilentDebugHeader = "#__secret_key__@babel/preset-env__don't_log_debug_header_and_resolved_targets";
exports.presetEnvSilentDebugHeader = presetEnvSilentDebugHeader;
function stringifyTargetsMultiline(targets) {
return JSON.stringify((0, _helperCompilationTargets.prettifyTargets)(targets), null, 2);
}
function stringifyTargets(targets) {
return JSON.stringify(targets).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
}

View file

@ -0,0 +1,9 @@
"use strict";
exports.__esModule = true;
exports.defineProvider = defineProvider;
function defineProvider(factory) {
// This will allow us to do some things
return factory;
}

View file

@ -0,0 +1,96 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _babel = _interopRequireWildcard(require("@babel/core"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
types: t
} = _babel.default || _babel;
class ImportsCache {
constructor(resolver) {
this._imports = new WeakMap();
this._anonymousImports = new WeakMap();
this._lastImports = new WeakMap();
this._resolver = resolver;
}
storeAnonymous(programPath, url,
// eslint-disable-next-line no-undef
getVal) {
const key = this._normalizeKey(programPath, url);
const imports = this._ensure(this._anonymousImports, programPath, Set);
if (imports.has(key)) return;
const node = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)));
imports.add(key);
this._injectImport(programPath, node);
}
storeNamed(programPath, url, name, getVal) {
const key = this._normalizeKey(programPath, url, name);
const imports = this._ensure(this._imports, programPath, Map);
if (!imports.has(key)) {
const {
node,
name: id
} = getVal(programPath.node.sourceType === "script", t.stringLiteral(this._resolver(url)), t.identifier(name));
imports.set(key, id);
this._injectImport(programPath, node);
}
return t.identifier(imports.get(key));
}
_injectImport(programPath, node) {
const lastImport = this._lastImports.get(programPath);
let newNodes;
if (lastImport && lastImport.node &&
// Sometimes the AST is modified and the "last import"
// we have has been replaced
lastImport.parent === programPath.node && lastImport.container === programPath.node.body) {
newNodes = lastImport.insertAfter(node);
} else {
newNodes = programPath.unshiftContainer("body", node);
}
const newNode = newNodes[newNodes.length - 1];
this._lastImports.set(programPath, newNode);
/*
let lastImport;
programPath.get("body").forEach(path => {
if (path.isImportDeclaration()) lastImport = path;
if (
path.isExpressionStatement() &&
isRequireCall(path.get("expression"))
) {
lastImport = path;
}
if (
path.isVariableDeclaration() &&
path.get("declarations").length === 1 &&
(isRequireCall(path.get("declarations.0.init")) ||
(path.get("declarations.0.init").isMemberExpression() &&
isRequireCall(path.get("declarations.0.init.object"))))
) {
lastImport = path;
}
});*/
}
_ensure(map, programPath, Collection) {
let collection = map.get(programPath);
if (!collection) {
collection = new Collection();
map.set(programPath, collection);
}
return collection;
}
_normalizeKey(programPath, url, name = "") {
const {
sourceType
} = programPath.node;
// If we rely on the imported binding (the "name" parameter), we also need to cache
// based on the sourceType. This is because the module transforms change the names
// of the import variables.
return `${name && sourceType}::${url}::${name}`;
}
}
exports.default = ImportsCache;

View file

@ -0,0 +1,275 @@
"use strict";
exports.__esModule = true;
exports.default = definePolyfillProvider;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperCompilationTargets = _interopRequireWildcard(require("@babel/helper-compilation-targets"));
var _utils = require("./utils");
var _importsCache = _interopRequireDefault(require("./imports-cache"));
var _debugUtils = require("./debug-utils");
var _normalizeOptions = require("./normalize-options");
var v = _interopRequireWildcard(require("./visitors"));
var deps = _interopRequireWildcard(require("./node/dependencies"));
var _metaResolver = _interopRequireDefault(require("./meta-resolver"));
const _excluded = ["method", "targets", "ignoreBrowserslistConfig", "configPath", "debug", "shouldInjectPolyfill", "absoluteImports"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
const getTargets = _helperCompilationTargets.default.default || _helperCompilationTargets.default;
function resolveOptions(options, babelApi) {
const {
method,
targets: targetsOption,
ignoreBrowserslistConfig,
configPath,
debug,
shouldInjectPolyfill,
absoluteImports
} = options,
providerOptions = _objectWithoutPropertiesLoose(options, _excluded);
if (isEmpty(options)) {
throw new Error(`\
This plugin requires options, for example:
{
"plugins": [
["<plugin name>", { method: "usage-pure" }]
]
}
See more options at https://github.com/babel/babel-polyfills/blob/main/docs/usage.md`);
}
let methodName;
if (method === "usage-global") methodName = "usageGlobal";else if (method === "entry-global") methodName = "entryGlobal";else if (method === "usage-pure") methodName = "usagePure";else if (typeof method !== "string") {
throw new Error(".method must be a string");
} else {
throw new Error(`.method must be one of "entry-global", "usage-global"` + ` or "usage-pure" (received ${JSON.stringify(method)})`);
}
if (typeof shouldInjectPolyfill === "function") {
if (options.include || options.exclude) {
throw new Error(`.include and .exclude are not supported when using the` + ` .shouldInjectPolyfill function.`);
}
} else if (shouldInjectPolyfill != null) {
throw new Error(`.shouldInjectPolyfill must be a function, or undefined` + ` (received ${JSON.stringify(shouldInjectPolyfill)})`);
}
if (absoluteImports != null && typeof absoluteImports !== "boolean" && typeof absoluteImports !== "string") {
throw new Error(`.absoluteImports must be a boolean, a string, or undefined` + ` (received ${JSON.stringify(absoluteImports)})`);
}
let targets;
if (
// If any browserslist-related option is specified, fallback to the old
// behavior of not using the targets specified in the top-level options.
targetsOption || configPath || ignoreBrowserslistConfig) {
const targetsObj = typeof targetsOption === "string" || Array.isArray(targetsOption) ? {
browsers: targetsOption
} : targetsOption;
targets = getTargets(targetsObj, {
ignoreBrowserslistConfig,
configPath
});
} else {
targets = babelApi.targets();
}
return {
method,
methodName,
targets,
absoluteImports: absoluteImports != null ? absoluteImports : false,
shouldInjectPolyfill,
debug: !!debug,
providerOptions: providerOptions
};
}
function instantiateProvider(factory, options, missingDependencies, dirname, debugLog, babelApi) {
const {
method,
methodName,
targets,
debug,
shouldInjectPolyfill,
providerOptions,
absoluteImports
} = resolveOptions(options, babelApi);
const getUtils = (0, _utils.createUtilsGetter)(new _importsCache.default(moduleName => deps.resolve(dirname, moduleName, absoluteImports)));
// eslint-disable-next-line prefer-const
let include, exclude;
let polyfillsSupport;
let polyfillsNames;
let filterPolyfills;
const depsCache = new Map();
const api = {
babel: babelApi,
getUtils,
method: options.method,
targets,
createMetaResolver: _metaResolver.default,
shouldInjectPolyfill(name) {
if (polyfillsNames === undefined) {
throw new Error(`Internal error in the ${factory.name} provider: ` + `shouldInjectPolyfill() can't be called during initialization.`);
}
if (!polyfillsNames.has(name)) {
console.warn(`Internal error in the ${providerName} provider: ` + `unknown polyfill "${name}".`);
}
if (filterPolyfills && !filterPolyfills(name)) return false;
let shouldInject = (0, _helperCompilationTargets.isRequired)(name, targets, {
compatData: polyfillsSupport,
includes: include,
excludes: exclude
});
if (shouldInjectPolyfill) {
shouldInject = shouldInjectPolyfill(name, shouldInject);
if (typeof shouldInject !== "boolean") {
throw new Error(`.shouldInjectPolyfill must return a boolean.`);
}
}
return shouldInject;
},
debug(name) {
var _debugLog, _debugLog$polyfillsSu;
debugLog().found = true;
if (!debug || !name) return;
if (debugLog().polyfills.has(providerName)) return;
debugLog().polyfills.add(name);
(_debugLog$polyfillsSu = (_debugLog = debugLog()).polyfillsSupport) != null ? _debugLog$polyfillsSu : _debugLog.polyfillsSupport = polyfillsSupport;
},
assertDependency(name, version = "*") {
if (missingDependencies === false) return;
if (absoluteImports) {
// If absoluteImports is not false, we will try resolving
// the dependency and throw if it's not possible. We can
// skip the check here.
return;
}
const dep = version === "*" ? name : `${name}@^${version}`;
const found = missingDependencies.all ? false : mapGetOr(depsCache, `${name} :: ${dirname}`, () => deps.has(dirname, name));
if (!found) {
debugLog().missingDeps.add(dep);
}
}
};
const provider = factory(api, providerOptions, dirname);
const providerName = provider.name || factory.name;
if (typeof provider[methodName] !== "function") {
throw new Error(`The "${providerName}" provider doesn't support the "${method}" polyfilling method.`);
}
if (Array.isArray(provider.polyfills)) {
polyfillsNames = new Set(provider.polyfills);
filterPolyfills = provider.filterPolyfills;
} else if (provider.polyfills) {
polyfillsNames = new Set(Object.keys(provider.polyfills));
polyfillsSupport = provider.polyfills;
filterPolyfills = provider.filterPolyfills;
} else {
polyfillsNames = new Set();
}
({
include,
exclude
} = (0, _normalizeOptions.validateIncludeExclude)(providerName, polyfillsNames, providerOptions.include || [], providerOptions.exclude || []));
return {
debug,
method,
targets,
provider,
providerName,
callProvider(payload, path) {
const utils = getUtils(path);
provider[methodName](payload, utils, path);
}
};
}
function definePolyfillProvider(factory) {
return (0, _helperPluginUtils.declare)((babelApi, options, dirname) => {
babelApi.assertVersion("^7.0.0 || ^8.0.0-alpha.0");
const {
traverse
} = babelApi;
let debugLog;
const missingDependencies = (0, _normalizeOptions.applyMissingDependenciesDefaults)(options, babelApi);
const {
debug,
method,
targets,
provider,
providerName,
callProvider
} = instantiateProvider(factory, options, missingDependencies, dirname, () => debugLog, babelApi);
const createVisitor = method === "entry-global" ? v.entry : v.usage;
const visitor = provider.visitor ? traverse.visitors.merge([createVisitor(callProvider), provider.visitor]) : createVisitor(callProvider);
if (debug && debug !== _debugUtils.presetEnvSilentDebugHeader) {
console.log(`${providerName}: \`DEBUG\` option`);
console.log(`\nUsing targets: ${(0, _debugUtils.stringifyTargetsMultiline)(targets)}`);
console.log(`\nUsing polyfills with \`${method}\` method:`);
}
const {
runtimeName
} = provider;
return {
name: "inject-polyfills",
visitor,
pre(file) {
var _provider$pre;
if (runtimeName) {
if (file.get("runtimeHelpersModuleName") && file.get("runtimeHelpersModuleName") !== runtimeName) {
console.warn(`Two different polyfill providers` + ` (${file.get("runtimeHelpersModuleProvider")}` + ` and ${providerName}) are trying to define two` + ` conflicting @babel/runtime alternatives:` + ` ${file.get("runtimeHelpersModuleName")} and ${runtimeName}.` + ` The second one will be ignored.`);
} else {
file.set("runtimeHelpersModuleName", runtimeName);
file.set("runtimeHelpersModuleProvider", providerName);
}
}
debugLog = {
polyfills: new Set(),
polyfillsSupport: undefined,
found: false,
providers: new Set(),
missingDeps: new Set()
};
(_provider$pre = provider.pre) == null ? void 0 : _provider$pre.apply(this, arguments);
},
post() {
var _provider$post;
(_provider$post = provider.post) == null ? void 0 : _provider$post.apply(this, arguments);
if (missingDependencies !== false) {
if (missingDependencies.log === "per-file") {
deps.logMissing(debugLog.missingDeps);
} else {
deps.laterLogMissing(debugLog.missingDeps);
}
}
if (!debug) return;
if (this.filename) console.log(`\n[${this.filename}]`);
if (debugLog.polyfills.size === 0) {
console.log(method === "entry-global" ? debugLog.found ? `Based on your targets, the ${providerName} polyfill did not add any polyfill.` : `The entry point for the ${providerName} polyfill has not been found.` : `Based on your code and targets, the ${providerName} polyfill did not add any polyfill.`);
return;
}
if (method === "entry-global") {
console.log(`The ${providerName} polyfill entry has been replaced with ` + `the following polyfills:`);
} else {
console.log(`The ${providerName} polyfill added the following polyfills:`);
}
for (const name of debugLog.polyfills) {
var _debugLog$polyfillsSu2;
if ((_debugLog$polyfillsSu2 = debugLog.polyfillsSupport) != null && _debugLog$polyfillsSu2[name]) {
const filteredTargets = (0, _helperCompilationTargets.getInclusionReasons)(name, targets, debugLog.polyfillsSupport);
const formattedTargets = JSON.stringify(filteredTargets).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
console.log(` ${name} ${formattedTargets}`);
} else {
console.log(` ${name}`);
}
}
}
};
});
}
function mapGetOr(map, key, getDefault) {
let val = map.get(key);
if (val === undefined) {
val = getDefault();
map.set(key, val);
}
return val;
}
function isEmpty(obj) {
return Object.keys(obj).length === 0;
}

View file

@ -0,0 +1,52 @@
"use strict";
exports.__esModule = true;
exports.default = createMetaResolver;
var _utils = require("./utils");
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
function createMetaResolver(polyfills) {
const {
static: staticP,
instance: instanceP,
global: globalP
} = polyfills;
return meta => {
if (meta.kind === "global" && globalP && (0, _utils.has)(globalP, meta.name)) {
return {
kind: "global",
desc: globalP[meta.name],
name: meta.name
};
}
if (meta.kind === "property" || meta.kind === "in") {
const {
placement,
object,
key
} = meta;
if (object && placement === "static") {
if (globalP && PossibleGlobalObjects.has(object) && (0, _utils.has)(globalP, key)) {
return {
kind: "global",
desc: globalP[key],
name: key
};
}
if (staticP && (0, _utils.has)(staticP, object) && (0, _utils.has)(staticP[object], key)) {
return {
kind: "static",
desc: staticP[object][key],
name: `${object}$${key}`
};
}
}
if (instanceP && (0, _utils.has)(instanceP, key)) {
return {
kind: "instance",
desc: instanceP[key],
name: `${key}`
};
}
}
};
}

View file

@ -0,0 +1,67 @@
"use strict";
exports.__esModule = true;
exports.has = has;
exports.laterLogMissing = laterLogMissing;
exports.logMissing = logMissing;
exports.resolve = resolve;
var _path = _interopRequireDefault(require("path"));
var _lodash = _interopRequireDefault(require("lodash.debounce"));
var _resolve = _interopRequireDefault(require("resolve"));
var _module = require("module");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const nativeRequireResolve = parseFloat(process.versions.node) >= 8.9;
// eslint-disable-line
function myResolve(name, basedir) {
if (nativeRequireResolve) {
return require.resolve(name, {
paths: [basedir]
}).replace(/\\/g, "/");
} else {
return _resolve.default.sync(name, {
basedir
}).replace(/\\/g, "/");
}
}
function resolve(dirname, moduleName, absoluteImports) {
if (absoluteImports === false) return moduleName;
let basedir = dirname;
if (typeof absoluteImports === "string") {
basedir = _path.default.resolve(basedir, absoluteImports);
}
try {
return myResolve(moduleName, basedir);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
throw Object.assign(new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), {
code: "BABEL_POLYFILL_NOT_FOUND",
polyfill: moduleName,
dirname
});
}
}
function has(basedir, name) {
try {
myResolve(name, basedir);
return true;
} catch (_unused) {
return false;
}
}
function logMissing(missingDeps) {
if (missingDeps.size === 0) return;
const deps = Array.from(missingDeps).sort().join(" ");
console.warn("\nSome polyfills have been added but are not present in your dependencies.\n" + "Please run one of the following commands:\n" + `\tnpm install --save ${deps}\n` + `\tyarn add ${deps}\n`);
process.exitCode = 1;
}
let allMissingDeps = new Set();
const laterLogMissingDependencies = (0, _lodash.default)(() => {
logMissing(allMissingDeps);
allMissingDeps = new Set();
}, 100);
function laterLogMissing(missingDeps) {
if (missingDeps.size === 0) return;
missingDeps.forEach(name => allMissingDeps.add(name));
laterLogMissingDependencies();
}

View file

@ -0,0 +1,70 @@
"use strict";
exports.__esModule = true;
exports.applyMissingDependenciesDefaults = applyMissingDependenciesDefaults;
exports.validateIncludeExclude = validateIncludeExclude;
var _utils = require("./utils");
function patternToRegExp(pattern) {
if (pattern instanceof RegExp) return pattern;
try {
return new RegExp(`^${pattern}$`);
} catch (_unused) {
return null;
}
}
function buildUnusedError(label, unused) {
if (!unused.length) return "";
return ` - The following "${label}" patterns didn't match any polyfill:\n` + unused.map(original => ` ${String(original)}\n`).join("");
}
function buldDuplicatesError(duplicates) {
if (!duplicates.size) return "";
return ` - The following polyfills were matched both by "include" and "exclude" patterns:\n` + Array.from(duplicates, name => ` ${name}\n`).join("");
}
function validateIncludeExclude(provider, polyfills, includePatterns, excludePatterns) {
let current;
const filter = pattern => {
const regexp = patternToRegExp(pattern);
if (!regexp) return false;
let matched = false;
for (const polyfill of polyfills) {
if (regexp.test(polyfill)) {
matched = true;
current.add(polyfill);
}
}
return !matched;
};
// prettier-ignore
const include = current = new Set();
const unusedInclude = Array.from(includePatterns).filter(filter);
// prettier-ignore
const exclude = current = new Set();
const unusedExclude = Array.from(excludePatterns).filter(filter);
const duplicates = (0, _utils.intersection)(include, exclude);
if (duplicates.size > 0 || unusedInclude.length > 0 || unusedExclude.length > 0) {
throw new Error(`Error while validating the "${provider}" provider options:\n` + buildUnusedError("include", unusedInclude) + buildUnusedError("exclude", unusedExclude) + buldDuplicatesError(duplicates));
}
return {
include,
exclude
};
}
function applyMissingDependenciesDefaults(options, babelApi) {
const {
missingDependencies = {}
} = options;
if (missingDependencies === false) return false;
const caller = babelApi.caller(caller => caller == null ? void 0 : caller.name);
const {
log = "deferred",
inject = caller === "rollup-plugin-babel" ? "throw" : "import",
all = false
} = missingDependencies;
return {
log,
inject,
all
};
}

View file

@ -0,0 +1,3 @@
"use strict";
exports.__esModule = true;

View file

@ -0,0 +1,165 @@
"use strict";
exports.__esModule = true;
exports.createUtilsGetter = createUtilsGetter;
exports.getImportSource = getImportSource;
exports.getRequireSource = getRequireSource;
exports.has = has;
exports.intersection = intersection;
exports.resolveKey = resolveKey;
exports.resolveSource = resolveSource;
var _babel = _interopRequireWildcard(require("@babel/core"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
types: t,
template: template
} = _babel.default || _babel;
function intersection(a, b) {
const result = new Set();
a.forEach(v => b.has(v) && result.add(v));
return result;
}
function has(object, key) {
return Object.prototype.hasOwnProperty.call(object, key);
}
function getType(target) {
return Object.prototype.toString.call(target).slice(8, -1);
}
function resolveId(path) {
if (path.isIdentifier() && !path.scope.hasBinding(path.node.name, /* noGlobals */true)) {
return path.node.name;
}
if (path.isPure()) {
const {
deopt
} = path.evaluate();
if (deopt && deopt.isIdentifier()) {
return deopt.node.name;
}
}
}
function resolveKey(path, computed = false) {
const {
scope
} = path;
if (path.isStringLiteral()) return path.node.value;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || path.parent.computed)) {
return path.node.name;
}
if (computed && path.isMemberExpression() && path.get("object").isIdentifier({
name: "Symbol"
}) && !scope.hasBinding("Symbol", /* noGlobals */true)) {
const sym = resolveKey(path.get("property"), path.node.computed);
if (sym) return "Symbol." + sym;
}
if (isIdentifier ? scope.hasBinding(path.node.name, /* noGlobals */true) : path.isPure()) {
const {
value
} = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(obj) {
if (obj.isMemberExpression() && obj.get("property").isIdentifier({
name: "prototype"
})) {
const id = resolveId(obj.get("object"));
if (id) {
return {
id,
placement: "prototype"
};
}
return {
id: null,
placement: null
};
}
const id = resolveId(obj);
if (id) {
return {
id,
placement: "static"
};
}
if (obj.isRegExpLiteral()) {
return {
id: "RegExp",
placement: "prototype"
};
} else if (obj.isFunction()) {
return {
id: "Function",
placement: "prototype"
};
} else if (obj.isPure()) {
const {
value
} = obj.evaluate();
if (value !== undefined) {
return {
id: getType(value),
placement: "prototype"
};
}
}
return {
id: null,
placement: null
};
}
function getImportSource({
node
}) {
if (node.specifiers.length === 0) return node.source.value;
}
function getRequireSource({
node
}) {
if (!t.isExpressionStatement(node)) return;
const {
expression
} = node;
if (t.isCallExpression(expression) && t.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t.isStringLiteral(expression.arguments[0])) {
return expression.arguments[0].value;
}
}
function hoist(node) {
// @ts-expect-error
node._blockHoist = 3;
return node;
}
function createUtilsGetter(cache) {
return path => {
const prog = path.findParent(p => p.isProgram());
return {
injectGlobalImport(url) {
cache.storeAnonymous(prog, url, (isScript, source) => {
return isScript ? template.statement.ast`require(${source})` : t.importDeclaration([], source);
});
},
injectNamedImport(url, name, hint = name) {
return cache.storeNamed(prog, url, name, (isScript, source, name) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`
var ${id} = require(${source}).${name}
`) : t.importDeclaration([t.importSpecifier(id, name)], source),
name: id.name
};
});
},
injectDefaultImport(url, hint = url) {
return cache.storeNamed(prog, url, "default", (isScript, source) => {
const id = prog.scope.generateUidIdentifier(hint);
return {
node: isScript ? hoist(template.statement.ast`var ${id} = require(${source})`) : t.importDeclaration([t.importDefaultSpecifier(id)], source),
name: id.name
};
});
}
};
};
}

View file

@ -0,0 +1,26 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _utils = require("../utils");
var _default = callProvider => ({
ImportDeclaration(path) {
const source = (0, _utils.getImportSource)(path);
if (!source) return;
callProvider({
kind: "import",
source
}, path);
},
Program(path) {
path.get("body").forEach(bodyPath => {
const source = (0, _utils.getRequireSource)(bodyPath);
if (!source) return;
callProvider({
kind: "import",
source
}, bodyPath);
});
}
});
exports.default = _default;

View file

@ -0,0 +1,9 @@
"use strict";
exports.__esModule = true;
exports.usage = exports.entry = void 0;
var _usage = _interopRequireDefault(require("./usage"));
exports.usage = _usage.default;
var _entry = _interopRequireDefault(require("./entry"));
exports.entry = _entry.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View file

@ -0,0 +1,91 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _utils = require("../utils");
var _default = callProvider => {
function property(object, key, placement, path) {
return callProvider({
kind: "property",
object,
key,
placement
}, path);
}
return {
// Symbol(), new Promise
ReferencedIdentifier(path) {
const {
node: {
name
},
scope
} = path;
if (scope.getBindingIdentifier(name)) return;
callProvider({
kind: "global",
name
}, path);
},
MemberExpression(path) {
const key = (0, _utils.resolveKey)(path.get("property"), path.node.computed);
if (!key || key === "prototype") return;
const object = path.get("object");
if (object.isIdentifier()) {
const binding = object.scope.getBinding(object.node.name);
if (binding && binding.path.isImportNamespaceSpecifier()) return;
}
const source = (0, _utils.resolveSource)(object);
return property(source.id, key, source.placement, path);
},
ObjectPattern(path) {
const {
parentPath,
parent
} = path;
let obj;
// const { keys, values } = Object
if (parentPath.isVariableDeclarator()) {
obj = parentPath.get("init");
// ({ keys, values } = Object)
} else if (parentPath.isAssignmentExpression()) {
obj = parentPath.get("right");
// !function ({ keys, values }) {...} (Object)
// resolution does not work after properties transform :-(
} else if (parentPath.isFunction()) {
const grand = parentPath.parentPath;
if (grand.isCallExpression() || grand.isNewExpression()) {
if (grand.node.callee === parent) {
obj = grand.get("arguments")[path.key];
}
}
}
let id = null;
let placement = null;
if (obj) ({
id,
placement
} = (0, _utils.resolveSource)(obj));
for (const prop of path.get("properties")) {
if (prop.isObjectProperty()) {
const key = (0, _utils.resolveKey)(prop.get("key"));
if (key) property(id, key, placement, prop);
}
}
},
BinaryExpression(path) {
if (path.node.operator !== "in") return;
const source = (0, _utils.resolveSource)(path.get("right"));
const key = (0, _utils.resolveKey)(path.get("left"), true);
if (!key) return;
callProvider({
kind: "in",
object: source.id,
key,
placement: source.placement
}, path);
}
};
};
exports.default = _default;

View file

@ -0,0 +1,59 @@
{
"name": "@babel/helper-define-polyfill-provider",
"version": "0.4.4",
"description": "Babel helper to create your own polyfill provider",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel-polyfills.git",
"directory": "packages/babel-helper-define-polyfill-provider"
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"browser": {
"./lib/node/dependencies.js": "./lib/browser/dependencies.js",
"./src/node/dependencies.js": "./src/browser/dependencies.js"
},
"exports": {
".": [
{
"import": {
"node": "./esm/index.node.mjs",
"browser": "./esm/index.browser.mjs"
},
"default": "./lib/index.js"
},
"./lib/index.js"
],
"./package.json": "./package.json"
},
"dependencies": {
"@babel/helper-compilation-targets": "^7.22.6",
"@babel/helper-plugin-utils": "^7.22.5",
"debug": "^4.1.1",
"lodash.debounce": "^4.0.8",
"resolve": "^1.14.2"
},
"peerDependencies": {
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
},
"devDependencies": {
"@babel/cli": "^7.22.6",
"@babel/core": "^7.22.6",
"@babel/generator": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/traverse": "^7.22.6",
"babel-loader": "^8.1.0",
"rollup": "^2.3.2",
"rollup-plugin-babel": "^4.4.0",
"strip-ansi": "^6.0.0",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"gitHead": "984c56c59568283889c3f0f89e58d370e4fd10f8"
}

View file

@ -0,0 +1,49 @@
{
"name": "babel-plugin-polyfill-corejs3",
"version": "0.8.7",
"description": "A Babel plugin to inject imports to core-js@3 polyfills",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel-polyfills.git",
"directory": "packages/babel-plugin-polyfill-corejs3"
},
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "lib/index.js",
"exports": {
".": [
{
"import": "./esm/index.mjs",
"default": "./lib/index.js"
},
"./lib/index.js"
],
"./package.json": "./package.json"
},
"keywords": [
"babel-plugin"
],
"dependencies": {
"@babel/helper-define-polyfill-provider": "^0.4.4",
"core-js-compat": "^3.33.1"
},
"devDependencies": {
"@babel/core": "^7.22.6",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/plugin-proposal-decorators": "^7.22.15",
"@babel/plugin-transform-class-properties": "^7.22.5",
"@babel/plugin-transform-classes": "^7.22.6",
"@babel/plugin-transform-for-of": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/plugin-transform-runtime": "^7.22.15",
"@babel/plugin-transform-spread": "^7.22.5",
"core-js": "^3.33.1",
"core-js-pure": "^3.33.1"
},
"peerDependencies": {
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
},
"gitHead": "984c56c59568283889c3f0f89e58d370e4fd10f8"
}