index.mjs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. import corejs3Polyfills from '../core-js-compat/data.js';
  2. import getModulesListForTargetVersion from '../core-js-compat/get-modules-list-for-target-version.js';
  3. import * as _babel from '@babel/core';
  4. import corejsEntries from '../core-js-compat/entries.js';
  5. import defineProvider from '@babel/helper-define-polyfill-provider';
  6. // This file is automatically generated by scripts/build-corejs3-shipped-proposals.mjs
  7. var corejs3ShippedProposalsList = new Set(["esnext.suppressed-error.constructor", "esnext.array.from-async", "esnext.array.group", "esnext.array.group-to-map", "esnext.data-view.get-float16", "esnext.data-view.set-float16", "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.math.f16round", "esnext.promise.try", "esnext.symbol.async-dispose", "esnext.symbol.dispose", "esnext.symbol.metadata"]);
  8. const polyfillsOrder = {};
  9. Object.keys(corejs3Polyfills).forEach((name, index) => {
  10. polyfillsOrder[name] = index;
  11. });
  12. const define = (pure, global, name = global[0], exclude) => {
  13. return {
  14. name,
  15. pure,
  16. global: global.sort((a, b) => polyfillsOrder[a] - polyfillsOrder[b]),
  17. exclude
  18. };
  19. };
  20. const typed = (...modules) => define(null, [...modules, ...TypedArrayDependencies]);
  21. const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
  22. const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
  23. const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
  24. const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
  25. const ErrorDependencies = ["es.error.cause", "es.error.to-string"];
  26. const SuppressedErrorDependencies = ["esnext.suppressed-error.constructor", ...ErrorDependencies];
  27. const ArrayBufferDependencies = ["es.array-buffer.constructor", "es.array-buffer.slice", "es.data-view", "es.array-buffer.detached", "es.array-buffer.transfer", "es.array-buffer.transfer-to-fixed-length", "es.object.to-string"];
  28. 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", "esnext.typed-array.filter-reject", "esnext.typed-array.group-by", "esnext.typed-array.to-spliced", "esnext.typed-array.unique-by", ...ArrayBufferDependencies];
  29. const PromiseDependencies = ["es.promise", "es.object.to-string"];
  30. const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
  31. const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
  32. 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];
  33. const SetDependencies = ["es.set", "es.set.difference.v2", "es.set.intersection.v2", "es.set.is-disjoint-from.v2", "es.set.is-subset-of.v2", "es.set.is-superset-of.v2", "es.set.symmetric-difference.v2", "es.set.union.v2", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.is-disjoint-from", "esnext.set.is-subset-of", "esnext.set.is-superset-of", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.union", ...CommonIteratorsWithTag];
  34. const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", "esnext.weak-map.emplace", ...CommonIteratorsWithTag];
  35. const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
  36. const DOMExceptionDependencies = ["web.dom-exception.constructor", "web.dom-exception.stack", "web.dom-exception.to-string-tag", "es.error.to-string"];
  37. const URLSearchParamsDependencies = ["web.url-search-params", "web.url-search-params.delete", "web.url-search-params.has", "web.url-search-params.size", ...CommonIteratorsWithTag];
  38. const AsyncIteratorDependencies = ["esnext.async-iterator.constructor", ...PromiseDependencies];
  39. 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"];
  40. const IteratorDependencies = ["esnext.iterator.constructor", "es.object.to-string"];
  41. const DecoratorMetadataDependencies = ["esnext.symbol.metadata", "esnext.function.metadata"];
  42. const TypedArrayStaticMethods = base => ({
  43. from: define(null, ["es.typed-array.from", base, ...TypedArrayDependencies]),
  44. fromAsync: define(null, ["esnext.typed-array.from-async", base, ...PromiseDependenciesWithIterators, ...TypedArrayDependencies]),
  45. of: define(null, ["es.typed-array.of", base, ...TypedArrayDependencies])
  46. });
  47. const DataViewDependencies = ["es.data-view", ...ArrayBufferDependencies];
  48. const BuiltIns = {
  49. 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]),
  50. AsyncIterator: define("async-iterator/index", AsyncIteratorDependencies),
  51. AggregateError: define("aggregate-error", ["es.aggregate-error", ...ErrorDependencies, ...CommonIteratorsWithTag, "es.aggregate-error.cause"]),
  52. ArrayBuffer: define(null, ArrayBufferDependencies),
  53. DataView: define(null, DataViewDependencies),
  54. Date: define(null, ["es.date.to-string"]),
  55. DOMException: define("dom-exception/index", DOMExceptionDependencies),
  56. DisposableStack: define("disposable-stack/index", ["esnext.disposable-stack.constructor", "es.object.to-string", "esnext.iterator.dispose", ...SuppressedErrorDependencies]),
  57. Error: define(null, ErrorDependencies),
  58. EvalError: define(null, ErrorDependencies),
  59. Float32Array: typed("es.typed-array.float32-array"),
  60. Float64Array: typed("es.typed-array.float64-array"),
  61. Int8Array: typed("es.typed-array.int8-array"),
  62. Int16Array: typed("es.typed-array.int16-array"),
  63. Int32Array: typed("es.typed-array.int32-array"),
  64. Iterator: define("iterator/index", IteratorDependencies),
  65. Uint8Array: typed("es.typed-array.uint8-array", "esnext.uint8-array.set-from-base64", "esnext.uint8-array.set-from-hex", "esnext.uint8-array.to-base64", "esnext.uint8-array.to-hex"),
  66. Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
  67. Uint16Array: typed("es.typed-array.uint16-array"),
  68. Uint32Array: typed("es.typed-array.uint32-array"),
  69. Map: define("map/index", MapDependencies),
  70. Number: define(null, ["es.number.constructor"]),
  71. Observable: define("observable/index", ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag]),
  72. Promise: define("promise/index", PromiseDependencies),
  73. RangeError: define(null, ErrorDependencies),
  74. ReferenceError: define(null, ErrorDependencies),
  75. Reflect: define(null, ["es.reflect.to-string-tag", "es.object.to-string"]),
  76. RegExp: define(null, ["es.regexp.constructor", "es.regexp.dot-all", "es.regexp.exec", "es.regexp.sticky", "es.regexp.to-string"]),
  77. Set: define("set/index", SetDependencies),
  78. SuppressedError: define("suppressed-error", SuppressedErrorDependencies),
  79. Symbol: define("symbol/index", SymbolDependencies),
  80. SyntaxError: define(null, ErrorDependencies),
  81. TypeError: define(null, ErrorDependencies),
  82. URIError: define(null, ErrorDependencies),
  83. URL: define("url/index", ["web.url", "web.url.to-json", ...URLSearchParamsDependencies]),
  84. URLSearchParams: define("url-search-params/index", URLSearchParamsDependencies),
  85. WeakMap: define("weak-map/index", WeakMapDependencies),
  86. WeakSet: define("weak-set/index", WeakSetDependencies),
  87. atob: define("atob", ["web.atob", ...DOMExceptionDependencies]),
  88. btoa: define("btoa", ["web.btoa", ...DOMExceptionDependencies]),
  89. clearImmediate: define("clear-immediate", ["web.immediate"]),
  90. compositeKey: define("composite-key", ["esnext.composite-key"]),
  91. compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]),
  92. escape: define("escape", ["es.escape"]),
  93. fetch: define(null, PromiseDependencies),
  94. globalThis: define("global-this", ["es.global-this"]),
  95. parseFloat: define("parse-float", ["es.parse-float"]),
  96. parseInt: define("parse-int", ["es.parse-int"]),
  97. queueMicrotask: define("queue-microtask", ["web.queue-microtask"]),
  98. self: define("self", ["web.self"]),
  99. setImmediate: define("set-immediate", ["web.immediate"]),
  100. setInterval: define("set-interval", ["web.timers"]),
  101. setTimeout: define("set-timeout", ["web.timers"]),
  102. structuredClone: define("structured-clone", ["web.structured-clone", ...DOMExceptionDependencies, "es.array.iterator", "es.object.keys", "es.object.to-string", "es.map", "es.set"]),
  103. unescape: define("unescape", ["es.unescape"])
  104. };
  105. const StaticProperties = {
  106. AsyncIterator: {
  107. from: define("async-iterator/from", ["esnext.async-iterator.from", ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods, ...CommonIterators])
  108. },
  109. Array: {
  110. from: define("array/from", ["es.array.from", "es.string.iterator"]),
  111. fromAsync: define("array/from-async", ["esnext.array.from-async", ...PromiseDependenciesWithIterators]),
  112. isArray: define("array/is-array", ["es.array.is-array"]),
  113. isTemplateObject: define("array/is-template-object", ["esnext.array.is-template-object"]),
  114. of: define("array/of", ["es.array.of"])
  115. },
  116. ArrayBuffer: {
  117. isView: define(null, ["es.array-buffer.is-view"])
  118. },
  119. BigInt: {
  120. range: define("bigint/range", ["esnext.bigint.range", "es.object.to-string"])
  121. },
  122. Date: {
  123. now: define("date/now", ["es.date.now"])
  124. },
  125. Function: {
  126. isCallable: define("function/is-callable", ["esnext.function.is-callable"]),
  127. isConstructor: define("function/is-constructor", ["esnext.function.is-constructor"])
  128. },
  129. Iterator: {
  130. from: define("iterator/from", ["esnext.iterator.from", ...IteratorDependencies, ...CommonIterators]),
  131. range: define("iterator/range", ["esnext.iterator.range", "es.object.to-string"])
  132. },
  133. JSON: {
  134. isRawJSON: define("json/is-raw-json", ["esnext.json.is-raw-json"]),
  135. parse: define("json/parse", ["esnext.json.parse", "es.object.keys"]),
  136. rawJSON: define("json/raw-json", ["esnext.json.raw-json", "es.object.create", "es.object.freeze"]),
  137. stringify: define("json/stringify", ["es.json.stringify", "es.date.to-json"], "es.symbol")
  138. },
  139. Math: {
  140. DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]),
  141. RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]),
  142. acosh: define("math/acosh", ["es.math.acosh"]),
  143. asinh: define("math/asinh", ["es.math.asinh"]),
  144. atanh: define("math/atanh", ["es.math.atanh"]),
  145. cbrt: define("math/cbrt", ["es.math.cbrt"]),
  146. clamp: define("math/clamp", ["esnext.math.clamp"]),
  147. clz32: define("math/clz32", ["es.math.clz32"]),
  148. cosh: define("math/cosh", ["es.math.cosh"]),
  149. degrees: define("math/degrees", ["esnext.math.degrees"]),
  150. expm1: define("math/expm1", ["es.math.expm1"]),
  151. fround: define("math/fround", ["es.math.fround"]),
  152. f16round: define("math/f16round", ["esnext.math.f16round"]),
  153. fscale: define("math/fscale", ["esnext.math.fscale"]),
  154. hypot: define("math/hypot", ["es.math.hypot"]),
  155. iaddh: define("math/iaddh", ["esnext.math.iaddh"]),
  156. imul: define("math/imul", ["es.math.imul"]),
  157. imulh: define("math/imulh", ["esnext.math.imulh"]),
  158. isubh: define("math/isubh", ["esnext.math.isubh"]),
  159. log10: define("math/log10", ["es.math.log10"]),
  160. log1p: define("math/log1p", ["es.math.log1p"]),
  161. log2: define("math/log2", ["es.math.log2"]),
  162. radians: define("math/radians", ["esnext.math.radians"]),
  163. scale: define("math/scale", ["esnext.math.scale"]),
  164. seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]),
  165. sign: define("math/sign", ["es.math.sign"]),
  166. signbit: define("math/signbit", ["esnext.math.signbit"]),
  167. sinh: define("math/sinh", ["es.math.sinh"]),
  168. sumPrecise: define("math/sum-precise", ["esnext.math.sum-precise", "es.array.iterator"]),
  169. tanh: define("math/tanh", ["es.math.tanh"]),
  170. trunc: define("math/trunc", ["es.math.trunc"]),
  171. umulh: define("math/umulh", ["esnext.math.umulh"])
  172. },
  173. Map: {
  174. from: define("map/from", ["esnext.map.from", ...MapDependencies]),
  175. groupBy: define("map/group-by", ["es.map.group-by", ...MapDependencies]),
  176. keyBy: define("map/key-by", ["esnext.map.key-by", ...MapDependencies]),
  177. of: define("map/of", ["esnext.map.of", ...MapDependencies])
  178. },
  179. Number: {
  180. EPSILON: define("number/epsilon", ["es.number.epsilon"]),
  181. MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]),
  182. MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]),
  183. fromString: define("number/from-string", ["esnext.number.from-string"]),
  184. isFinite: define("number/is-finite", ["es.number.is-finite"]),
  185. isInteger: define("number/is-integer", ["es.number.is-integer"]),
  186. isNaN: define("number/is-nan", ["es.number.is-nan"]),
  187. isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]),
  188. parseFloat: define("number/parse-float", ["es.number.parse-float"]),
  189. parseInt: define("number/parse-int", ["es.number.parse-int"]),
  190. range: define("number/range", ["esnext.number.range", "es.object.to-string"])
  191. },
  192. Object: {
  193. assign: define("object/assign", ["es.object.assign"]),
  194. create: define("object/create", ["es.object.create"]),
  195. defineProperties: define("object/define-properties", ["es.object.define-properties"]),
  196. defineProperty: define("object/define-property", ["es.object.define-property"]),
  197. entries: define("object/entries", ["es.object.entries"]),
  198. freeze: define("object/freeze", ["es.object.freeze"]),
  199. fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]),
  200. getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]),
  201. getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]),
  202. getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]),
  203. getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]),
  204. getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]),
  205. groupBy: define("object/group-by", ["es.object.group-by", "es.object.create"]),
  206. hasOwn: define("object/has-own", ["es.object.has-own"]),
  207. is: define("object/is", ["es.object.is"]),
  208. isExtensible: define("object/is-extensible", ["es.object.is-extensible"]),
  209. isFrozen: define("object/is-frozen", ["es.object.is-frozen"]),
  210. isSealed: define("object/is-sealed", ["es.object.is-sealed"]),
  211. keys: define("object/keys", ["es.object.keys"]),
  212. preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]),
  213. seal: define("object/seal", ["es.object.seal"]),
  214. setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]),
  215. values: define("object/values", ["es.object.values"])
  216. },
  217. Promise: {
  218. all: define(null, PromiseDependenciesWithIterators),
  219. allSettled: define("promise/all-settled", ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
  220. any: define("promise/any", ["es.promise.any", "es.aggregate-error", ...PromiseDependenciesWithIterators]),
  221. race: define(null, PromiseDependenciesWithIterators),
  222. try: define("promise/try", ["esnext.promise.try", ...PromiseDependencies]),
  223. withResolvers: define("promise/with-resolvers", ["es.promise.with-resolvers", ...PromiseDependencies])
  224. },
  225. Reflect: {
  226. apply: define("reflect/apply", ["es.reflect.apply"]),
  227. construct: define("reflect/construct", ["es.reflect.construct"]),
  228. defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]),
  229. defineProperty: define("reflect/define-property", ["es.reflect.define-property"]),
  230. deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]),
  231. deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]),
  232. get: define("reflect/get", ["es.reflect.get"]),
  233. getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]),
  234. getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]),
  235. getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]),
  236. getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]),
  237. getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]),
  238. getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]),
  239. has: define("reflect/has", ["es.reflect.has"]),
  240. hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]),
  241. hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]),
  242. isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]),
  243. metadata: define("reflect/metadata", ["esnext.reflect.metadata"]),
  244. ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]),
  245. preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]),
  246. set: define("reflect/set", ["es.reflect.set"]),
  247. setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"])
  248. },
  249. RegExp: {
  250. escape: define("regexp/escape", ["esnext.regexp.escape"])
  251. },
  252. Set: {
  253. from: define("set/from", ["esnext.set.from", ...SetDependencies]),
  254. of: define("set/of", ["esnext.set.of", ...SetDependencies])
  255. },
  256. String: {
  257. cooked: define("string/cooked", ["esnext.string.cooked"]),
  258. dedent: define("string/dedent", ["esnext.string.dedent", "es.string.from-code-point", "es.weak-map"]),
  259. fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]),
  260. raw: define("string/raw", ["es.string.raw"])
  261. },
  262. Symbol: {
  263. asyncDispose: define("symbol/async-dispose", ["esnext.symbol.async-dispose", "esnext.async-iterator.async-dispose"]),
  264. asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]),
  265. customMatcher: define("symbol/custom-matcher", ["esnext.symbol.custom-matcher"]),
  266. dispose: define("symbol/dispose", ["esnext.symbol.dispose", "esnext.iterator.dispose"]),
  267. for: define("symbol/for", [], "es.symbol"),
  268. hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
  269. isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]),
  270. isRegistered: define("symbol/is-registered", ["esnext.symbol.is-registered", "es.symbol"]),
  271. isRegisteredSymbol: define("symbol/is-registered-symbol", ["esnext.symbol.is-registered-symbol", "es.symbol"]),
  272. isWellKnown: define("symbol/is-well-known", ["esnext.symbol.is-well-known", "es.symbol"]),
  273. isWellKnownSymbol: define("symbol/is-well-known-symbol", ["esnext.symbol.is-well-known-symbol", "es.symbol"]),
  274. iterator: define("symbol/iterator", ["es.symbol.iterator", ...CommonIteratorsWithTag]),
  275. keyFor: define("symbol/key-for", [], "es.symbol"),
  276. match: define("symbol/match", ["es.symbol.match", "es.string.match"]),
  277. matcher: define("symbol/matcher", ["esnext.symbol.matcher"]),
  278. matchAll: define("symbol/match-all", ["es.symbol.match-all", "es.string.match-all"]),
  279. metadata: define("symbol/metadata", DecoratorMetadataDependencies),
  280. metadataKey: define("symbol/metadata-key", ["esnext.symbol.metadata-key"]),
  281. observable: define("symbol/observable", ["esnext.symbol.observable"]),
  282. patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]),
  283. replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]),
  284. search: define("symbol/search", ["es.symbol.search", "es.string.search"]),
  285. species: define("symbol/species", ["es.symbol.species", "es.array.species"]),
  286. split: define("symbol/split", ["es.symbol.split", "es.string.split"]),
  287. toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]),
  288. 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"]),
  289. unscopables: define("symbol/unscopables", ["es.symbol.unscopables"])
  290. },
  291. URL: {
  292. canParse: define("url/can-parse", ["web.url.can-parse", "web.url"]),
  293. parse: define("url/parse", ["web.url.parse", "web.url"])
  294. },
  295. WeakMap: {
  296. from: define("weak-map/from", ["esnext.weak-map.from", ...WeakMapDependencies]),
  297. of: define("weak-map/of", ["esnext.weak-map.of", ...WeakMapDependencies])
  298. },
  299. WeakSet: {
  300. from: define("weak-set/from", ["esnext.weak-set.from", ...WeakSetDependencies]),
  301. of: define("weak-set/of", ["esnext.weak-set.of", ...WeakSetDependencies])
  302. },
  303. Int8Array: TypedArrayStaticMethods("es.typed-array.int8-array"),
  304. Uint8Array: {
  305. fromBase64: define(null, ["esnext.uint8-array.from-base64", ...TypedArrayDependencies]),
  306. fromHex: define(null, ["esnext.uint8-array.from-hex", ...TypedArrayDependencies]),
  307. ...TypedArrayStaticMethods("es.typed-array.uint8-array")
  308. },
  309. Uint8ClampedArray: TypedArrayStaticMethods("es.typed-array.uint8-clamped-array"),
  310. Int16Array: TypedArrayStaticMethods("es.typed-array.int16-array"),
  311. Uint16Array: TypedArrayStaticMethods("es.typed-array.uint16-array"),
  312. Int32Array: TypedArrayStaticMethods("es.typed-array.int32-array"),
  313. Uint32Array: TypedArrayStaticMethods("es.typed-array.uint32-array"),
  314. Float32Array: TypedArrayStaticMethods("es.typed-array.float32-array"),
  315. Float64Array: TypedArrayStaticMethods("es.typed-array.float64-array"),
  316. WebAssembly: {
  317. CompileError: define(null, ErrorDependencies),
  318. LinkError: define(null, ErrorDependencies),
  319. RuntimeError: define(null, ErrorDependencies)
  320. }
  321. };
  322. const InstanceProperties = {
  323. asIndexedPairs: define(null, ["esnext.async-iterator.as-indexed-pairs", ...AsyncIteratorDependencies, "esnext.iterator.as-indexed-pairs", ...IteratorDependencies]),
  324. at: define("instance/at", [
  325. // TODO: We should introduce overloaded instance methods definition
  326. // Before that is implemented, the `esnext.string.at` must be the first
  327. // In pure mode, the provider resolves the descriptor as a "pure" `esnext.string.at`
  328. // and treats the compat-data of `esnext.string.at` as the compat-data of
  329. // pure import `instance/at`. The first polyfill here should have the lowest corejs
  330. // supported versions.
  331. "esnext.string.at", "es.string.at-alternative", "es.array.at"]),
  332. anchor: define(null, ["es.string.anchor"]),
  333. big: define(null, ["es.string.big"]),
  334. bind: define("instance/bind", ["es.function.bind"]),
  335. blink: define(null, ["es.string.blink"]),
  336. bold: define(null, ["es.string.bold"]),
  337. codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]),
  338. codePoints: define("instance/code-points", ["esnext.string.code-points"]),
  339. concat: define("instance/concat", ["es.array.concat"], undefined, ["String"]),
  340. copyWithin: define("instance/copy-within", ["es.array.copy-within"]),
  341. demethodize: define("instance/demethodize", ["esnext.function.demethodize"]),
  342. description: define(null, ["es.symbol", "es.symbol.description"]),
  343. dotAll: define(null, ["es.regexp.dot-all"]),
  344. drop: define(null, ["esnext.async-iterator.drop", ...AsyncIteratorDependencies, "esnext.iterator.drop", ...IteratorDependencies]),
  345. emplace: define("instance/emplace", ["esnext.map.emplace", "esnext.weak-map.emplace"]),
  346. endsWith: define("instance/ends-with", ["es.string.ends-with"]),
  347. entries: define("instance/entries", ArrayNatureIteratorsWithTag),
  348. every: define("instance/every", ["es.array.every", "esnext.async-iterator.every",
  349. // TODO: add async iterator dependencies when we support sub-dependencies
  350. // esnext.async-iterator.every depends on es.promise
  351. // but we don't want to pull es.promise when esnext.async-iterator is disabled
  352. //
  353. // ...AsyncIteratorDependencies
  354. "esnext.iterator.every", ...IteratorDependencies]),
  355. exec: define(null, ["es.regexp.exec"]),
  356. fill: define("instance/fill", ["es.array.fill"]),
  357. filter: define("instance/filter", ["es.array.filter", "esnext.async-iterator.filter", "esnext.iterator.filter", ...IteratorDependencies]),
  358. filterReject: define("instance/filterReject", ["esnext.array.filter-reject"]),
  359. finally: define(null, ["es.promise.finally", ...PromiseDependencies]),
  360. find: define("instance/find", ["es.array.find", "esnext.async-iterator.find", "esnext.iterator.find", ...IteratorDependencies]),
  361. findIndex: define("instance/find-index", ["es.array.find-index"]),
  362. findLast: define("instance/find-last", ["es.array.find-last"]),
  363. findLastIndex: define("instance/find-last-index", ["es.array.find-last-index"]),
  364. fixed: define(null, ["es.string.fixed"]),
  365. flags: define("instance/flags", ["es.regexp.flags"]),
  366. flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map", "esnext.async-iterator.flat-map", "esnext.iterator.flat-map", ...IteratorDependencies]),
  367. flat: define("instance/flat", ["es.array.flat", "es.array.unscopables.flat"]),
  368. getFloat16: define(null, ["esnext.data-view.get-float16", ...DataViewDependencies]),
  369. getUint8Clamped: define(null, ["esnext.data-view.get-uint8-clamped", ...DataViewDependencies]),
  370. getYear: define(null, ["es.date.get-year"]),
  371. group: define("instance/group", ["esnext.array.group"]),
  372. groupBy: define("instance/group-by", ["esnext.array.group-by"]),
  373. groupByToMap: define("instance/group-by-to-map", ["esnext.array.group-by-to-map", "es.map", "es.object.to-string"]),
  374. groupToMap: define("instance/group-to-map", ["esnext.array.group-to-map", "es.map", "es.object.to-string"]),
  375. fontcolor: define(null, ["es.string.fontcolor"]),
  376. fontsize: define(null, ["es.string.fontsize"]),
  377. forEach: define("instance/for-each", ["es.array.for-each", "esnext.async-iterator.for-each", "esnext.iterator.for-each", ...IteratorDependencies, "web.dom-collections.for-each"]),
  378. includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
  379. indexed: define(null, ["esnext.async-iterator.indexed", ...AsyncIteratorDependencies, "esnext.iterator.indexed", ...IteratorDependencies]),
  380. indexOf: define("instance/index-of", ["es.array.index-of"]),
  381. isWellFormed: define("instance/is-well-formed", ["es.string.is-well-formed"]),
  382. italic: define(null, ["es.string.italics"]),
  383. join: define(null, ["es.array.join"]),
  384. keys: define("instance/keys", ArrayNatureIteratorsWithTag),
  385. lastIndex: define(null, ["esnext.array.last-index"]),
  386. lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]),
  387. lastItem: define(null, ["esnext.array.last-item"]),
  388. link: define(null, ["es.string.link"]),
  389. map: define("instance/map", ["es.array.map", "esnext.async-iterator.map", "esnext.iterator.map"]),
  390. match: define(null, ["es.string.match", "es.regexp.exec"]),
  391. matchAll: define("instance/match-all", ["es.string.match-all", "es.regexp.exec"]),
  392. name: define(null, ["es.function.name"]),
  393. padEnd: define("instance/pad-end", ["es.string.pad-end"]),
  394. padStart: define("instance/pad-start", ["es.string.pad-start"]),
  395. push: define("instance/push", ["es.array.push"]),
  396. reduce: define("instance/reduce", ["es.array.reduce", "esnext.async-iterator.reduce", "esnext.iterator.reduce", ...IteratorDependencies]),
  397. reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]),
  398. repeat: define("instance/repeat", ["es.string.repeat"]),
  399. replace: define(null, ["es.string.replace", "es.regexp.exec"]),
  400. replaceAll: define("instance/replace-all", ["es.string.replace-all", "es.string.replace", "es.regexp.exec"]),
  401. reverse: define("instance/reverse", ["es.array.reverse"]),
  402. search: define(null, ["es.string.search", "es.regexp.exec"]),
  403. setFloat16: define(null, ["esnext.data-view.set-float16", ...DataViewDependencies]),
  404. setUint8Clamped: define(null, ["esnext.data-view.set-uint8-clamped", ...DataViewDependencies]),
  405. setYear: define(null, ["es.date.set-year"]),
  406. slice: define("instance/slice", ["es.array.slice"]),
  407. small: define(null, ["es.string.small"]),
  408. some: define("instance/some", ["es.array.some", "esnext.async-iterator.some", "esnext.iterator.some", ...IteratorDependencies]),
  409. sort: define("instance/sort", ["es.array.sort"]),
  410. splice: define("instance/splice", ["es.array.splice"]),
  411. split: define(null, ["es.string.split", "es.regexp.exec"]),
  412. startsWith: define("instance/starts-with", ["es.string.starts-with"]),
  413. sticky: define(null, ["es.regexp.sticky"]),
  414. strike: define(null, ["es.string.strike"]),
  415. sub: define(null, ["es.string.sub"]),
  416. substr: define(null, ["es.string.substr"]),
  417. sup: define(null, ["es.string.sup"]),
  418. take: define(null, ["esnext.async-iterator.take", ...AsyncIteratorDependencies, "esnext.iterator.take", ...IteratorDependencies]),
  419. test: define(null, ["es.regexp.test", "es.regexp.exec"]),
  420. toArray: define(null, ["esnext.async-iterator.to-array", ...AsyncIteratorDependencies, "esnext.iterator.to-array", ...IteratorDependencies]),
  421. toAsync: define(null, ["esnext.iterator.to-async", ...IteratorDependencies, ...AsyncIteratorDependencies, ...AsyncIteratorProblemMethods]),
  422. toExponential: define(null, ["es.number.to-exponential"]),
  423. toFixed: define(null, ["es.number.to-fixed"]),
  424. toGMTString: define(null, ["es.date.to-gmt-string"]),
  425. toISOString: define(null, ["es.date.to-iso-string"]),
  426. toJSON: define(null, ["es.date.to-json"]),
  427. toPrecision: define(null, ["es.number.to-precision"]),
  428. toReversed: define("instance/to-reversed", ["es.array.to-reversed"]),
  429. toSorted: define("instance/to-sorted", ["es.array.to-sorted", "es.array.sort"]),
  430. toSpliced: define("instance/to-spliced", ["es.array.to-spliced"]),
  431. toString: define(null, ["es.object.to-string", "es.error.to-string", "es.date.to-string", "es.regexp.to-string"]),
  432. toWellFormed: define("instance/to-well-formed", ["es.string.to-well-formed"]),
  433. trim: define("instance/trim", ["es.string.trim"]),
  434. trimEnd: define("instance/trim-end", ["es.string.trim-end"]),
  435. trimLeft: define("instance/trim-left", ["es.string.trim-start"]),
  436. trimRight: define("instance/trim-right", ["es.string.trim-end"]),
  437. trimStart: define("instance/trim-start", ["es.string.trim-start"]),
  438. uniqueBy: define("instance/unique-by", ["esnext.array.unique-by", "es.map"]),
  439. unshift: define("instance/unshift", ["es.array.unshift"]),
  440. unThis: define("instance/un-this", ["esnext.function.un-this"]),
  441. values: define("instance/values", ArrayNatureIteratorsWithTag),
  442. with: define("instance/with", ["es.array.with"]),
  443. __defineGetter__: define(null, ["es.object.define-getter"]),
  444. __defineSetter__: define(null, ["es.object.define-setter"]),
  445. __lookupGetter__: define(null, ["es.object.lookup-getter"]),
  446. __lookupSetter__: define(null, ["es.object.lookup-setter"]),
  447. ["__proto__"]: define(null, ["es.object.proto"])
  448. };
  449. // This file contains the list of paths supported by @babel/runtime-corejs3.
  450. // It must _not_ be edited, as all new features should go through direct
  451. // injection of core-js-pure imports.
  452. const stable = new Set(["array", "array/from", "array/is-array", "array/of", "clear-immediate", "date/now", "instance/bind", "instance/code-point-at", "instance/concat", "instance/copy-within", "instance/ends-with", "instance/entries", "instance/every", "instance/fill", "instance/filter", "instance/find", "instance/find-index", "instance/flags", "instance/flat", "instance/flat-map", "instance/for-each", "instance/includes", "instance/index-of", "instance/keys", "instance/last-index-of", "instance/map", "instance/pad-end", "instance/pad-start", "instance/reduce", "instance/reduce-right", "instance/repeat", "instance/reverse", "instance/slice", "instance/some", "instance/sort", "instance/splice", "instance/starts-with", "instance/trim", "instance/trim-end", "instance/trim-left", "instance/trim-right", "instance/trim-start", "instance/values", "json/stringify", "map", "math/acosh", "math/asinh", "math/atanh", "math/cbrt", "math/clz32", "math/cosh", "math/expm1", "math/fround", "math/hypot", "math/imul", "math/log10", "math/log1p", "math/log2", "math/sign", "math/sinh", "math/tanh", "math/trunc", "number/epsilon", "number/is-finite", "number/is-integer", "number/is-nan", "number/is-safe-integer", "number/max-safe-integer", "number/min-safe-integer", "number/parse-float", "number/parse-int", "object/assign", "object/create", "object/define-properties", "object/define-property", "object/entries", "object/freeze", "object/from-entries", "object/get-own-property-descriptor", "object/get-own-property-descriptors", "object/get-own-property-names", "object/get-own-property-symbols", "object/get-prototype-of", "object/is", "object/is-extensible", "object/is-frozen", "object/is-sealed", "object/keys", "object/prevent-extensions", "object/seal", "object/set-prototype-of", "object/values", "parse-float", "parse-int", "promise", "queue-microtask", "reflect/apply", "reflect/construct", "reflect/define-property", "reflect/delete-property", "reflect/get", "reflect/get-own-property-descriptor", "reflect/get-prototype-of", "reflect/has", "reflect/is-extensible", "reflect/own-keys", "reflect/prevent-extensions", "reflect/set", "reflect/set-prototype-of", "set", "set-immediate", "set-interval", "set-timeout", "string/from-code-point", "string/raw", "symbol", "symbol/async-iterator", "symbol/for", "symbol/has-instance", "symbol/is-concat-spreadable", "symbol/iterator", "symbol/key-for", "symbol/match", "symbol/replace", "symbol/search", "symbol/species", "symbol/split", "symbol/to-primitive", "symbol/to-string-tag", "symbol/unscopables", "url", "url-search-params", "weak-map", "weak-set"]);
  453. const proposals = new Set([...stable, "aggregate-error", "composite-key", "composite-symbol", "global-this", "instance/at", "instance/code-points", "instance/match-all", "instance/replace-all", "math/clamp", "math/degrees", "math/deg-per-rad", "math/fscale", "math/iaddh", "math/imulh", "math/isubh", "math/rad-per-deg", "math/radians", "math/scale", "math/seeded-prng", "math/signbit", "math/umulh", "number/from-string", "observable", "reflect/define-metadata", "reflect/delete-metadata", "reflect/get-metadata", "reflect/get-metadata-keys", "reflect/get-own-metadata", "reflect/get-own-metadata-keys", "reflect/has-metadata", "reflect/has-own-metadata", "reflect/metadata", "symbol/dispose", "symbol/observable", "symbol/pattern-match"]);
  454. const {
  455. types: t$2
  456. } = _babel.default || _babel;
  457. function canSkipPolyfill(desc, path) {
  458. const {
  459. node,
  460. parent
  461. } = path;
  462. switch (desc.name) {
  463. case "es.string.split":
  464. {
  465. if (!t$2.isCallExpression(parent, {
  466. callee: node
  467. })) return false;
  468. if (parent.arguments.length < 1) return true;
  469. const splitter = parent.arguments[0];
  470. return t$2.isStringLiteral(splitter) || t$2.isTemplateLiteral(splitter);
  471. }
  472. }
  473. }
  474. const {
  475. types: t$1
  476. } = _babel.default || _babel;
  477. const BABEL_RUNTIME = "@babel/runtime-corejs3";
  478. function callMethod(path, id) {
  479. const {
  480. object
  481. } = path.node;
  482. let context1, context2;
  483. if (t$1.isIdentifier(object)) {
  484. context1 = object;
  485. context2 = t$1.cloneNode(object);
  486. } else {
  487. context1 = path.scope.generateDeclaredUidIdentifier("context");
  488. context2 = t$1.assignmentExpression("=", t$1.cloneNode(context1), object);
  489. }
  490. path.replaceWith(t$1.memberExpression(t$1.callExpression(id, [context2]), t$1.identifier("call")));
  491. path.parentPath.unshiftContainer("arguments", context1);
  492. }
  493. function isCoreJSSource(source) {
  494. if (typeof source === "string") {
  495. source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
  496. }
  497. return Object.prototype.hasOwnProperty.call(corejsEntries, source) && corejsEntries[source];
  498. }
  499. function coreJSModule(name) {
  500. return `core-js/modules/${name}.js`;
  501. }
  502. function coreJSPureHelper(name, useBabelRuntime, ext) {
  503. return useBabelRuntime ? `${BABEL_RUNTIME}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
  504. }
  505. const {
  506. types: t
  507. } = _babel.default || _babel;
  508. const presetEnvCompat = "#__secret_key__@babel/preset-env__compatibility";
  509. const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
  510. const uniqueObjects = ["array", "string", "iterator", "async-iterator", "dom-collections"].map(v => new RegExp(`[a-z]*\\.${v}\\..*`));
  511. const esnextFallback = (name, cb) => {
  512. if (cb(name)) return true;
  513. if (!name.startsWith("es.")) return false;
  514. const fallback = `esnext.${name.slice(3)}`;
  515. if (!corejs3Polyfills[fallback]) return false;
  516. return cb(fallback);
  517. };
  518. var index = defineProvider(function ({
  519. getUtils,
  520. method,
  521. shouldInjectPolyfill,
  522. createMetaResolver,
  523. debug,
  524. babel
  525. }, {
  526. version = 3,
  527. proposals: proposals$1,
  528. shippedProposals,
  529. [presetEnvCompat]: {
  530. noRuntimeName = false
  531. } = {},
  532. [runtimeCompat]: {
  533. useBabelRuntime = false,
  534. ext = ".js"
  535. } = {}
  536. }) {
  537. const isWebpack = babel.caller(caller => (caller == null ? void 0 : caller.name) === "babel-loader");
  538. const resolve = createMetaResolver({
  539. global: BuiltIns,
  540. static: StaticProperties,
  541. instance: InstanceProperties
  542. });
  543. const available = new Set(getModulesListForTargetVersion(version));
  544. function getCoreJSPureBase(useProposalBase) {
  545. return useBabelRuntime ? useProposalBase ? `${BABEL_RUNTIME}/core-js` : `${BABEL_RUNTIME}/core-js-stable` : useProposalBase ? "core-js-pure/features" : "core-js-pure/stable";
  546. }
  547. function maybeInjectGlobalImpl(name, utils) {
  548. if (shouldInjectPolyfill(name)) {
  549. debug(name);
  550. utils.injectGlobalImport(coreJSModule(name), name);
  551. return true;
  552. }
  553. return false;
  554. }
  555. function maybeInjectGlobal(names, utils, fallback = true) {
  556. for (const name of names) {
  557. if (fallback) {
  558. esnextFallback(name, name => maybeInjectGlobalImpl(name, utils));
  559. } else {
  560. maybeInjectGlobalImpl(name, utils);
  561. }
  562. }
  563. }
  564. function maybeInjectPure(desc, hint, utils, object) {
  565. if (desc.pure && !(object && desc.exclude && desc.exclude.includes(object)) && esnextFallback(desc.name, shouldInjectPolyfill)) {
  566. const {
  567. name
  568. } = desc;
  569. let useProposalBase = false;
  570. if (proposals$1 || shippedProposals && name.startsWith("esnext.")) {
  571. useProposalBase = true;
  572. } else if (name.startsWith("es.") && !available.has(name)) {
  573. useProposalBase = true;
  574. }
  575. if (useBabelRuntime && !(useProposalBase ? proposals : stable).has(desc.pure)) {
  576. return;
  577. }
  578. const coreJSPureBase = getCoreJSPureBase(useProposalBase);
  579. return utils.injectDefaultImport(`${coreJSPureBase}/${desc.pure}${ext}`, hint);
  580. }
  581. }
  582. function isFeatureStable(name) {
  583. if (name.startsWith("esnext.")) {
  584. const esName = `es.${name.slice(7)}`;
  585. // If its imaginative esName is not in latest compat data, it means
  586. // the proposal is not stage 4
  587. return esName in corejs3Polyfills;
  588. }
  589. return true;
  590. }
  591. return {
  592. name: "corejs3",
  593. runtimeName: noRuntimeName ? null : BABEL_RUNTIME,
  594. polyfills: corejs3Polyfills,
  595. filterPolyfills(name) {
  596. if (!available.has(name)) return false;
  597. if (proposals$1 || method === "entry-global") return true;
  598. if (shippedProposals && corejs3ShippedProposalsList.has(name)) {
  599. return true;
  600. }
  601. return isFeatureStable(name);
  602. },
  603. entryGlobal(meta, utils, path) {
  604. if (meta.kind !== "import") return;
  605. const modules = isCoreJSSource(meta.source);
  606. if (!modules) return;
  607. if (modules.length === 1 && meta.source === coreJSModule(modules[0]) && shouldInjectPolyfill(modules[0])) {
  608. // Avoid infinite loop: do not replace imports with a new copy of
  609. // themselves.
  610. debug(null);
  611. return;
  612. }
  613. const modulesSet = new Set(modules);
  614. const filteredModules = modules.filter(module => {
  615. if (!module.startsWith("esnext.")) return true;
  616. const stable = module.replace("esnext.", "es.");
  617. if (modulesSet.has(stable) && shouldInjectPolyfill(stable)) {
  618. return false;
  619. }
  620. return true;
  621. });
  622. maybeInjectGlobal(filteredModules, utils, false);
  623. path.remove();
  624. },
  625. usageGlobal(meta, utils, path) {
  626. const resolved = resolve(meta);
  627. if (!resolved) return;
  628. if (canSkipPolyfill(resolved.desc, path)) return;
  629. let deps = resolved.desc.global;
  630. if (resolved.kind !== "global" && "object" in meta && meta.object && meta.placement === "prototype") {
  631. const low = meta.object.toLowerCase();
  632. deps = deps.filter(m => uniqueObjects.some(v => v.test(m)) ? m.includes(low) : true);
  633. }
  634. maybeInjectGlobal(deps, utils);
  635. return true;
  636. },
  637. usagePure(meta, utils, path) {
  638. if (meta.kind === "in") {
  639. if (meta.key === "Symbol.iterator") {
  640. path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("is-iterable", useBabelRuntime, ext), "isIterable"), [path.node.right] // meta.kind === "in" narrows this
  641. ));
  642. }
  643. return;
  644. }
  645. if (path.parentPath.isUnaryExpression({
  646. operator: "delete"
  647. })) return;
  648. if (meta.kind === "property") {
  649. // We can't compile destructuring and updateExpression.
  650. if (!path.isMemberExpression()) return;
  651. if (!path.isReferenced()) return;
  652. if (path.parentPath.isUpdateExpression()) return;
  653. if (t.isSuper(path.node.object)) {
  654. return;
  655. }
  656. if (meta.key === "Symbol.iterator") {
  657. if (!shouldInjectPolyfill("es.symbol.iterator")) return;
  658. const {
  659. parent,
  660. node
  661. } = path;
  662. if (t.isCallExpression(parent, {
  663. callee: node
  664. })) {
  665. if (parent.arguments.length === 0) {
  666. path.parentPath.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator", useBabelRuntime, ext), "getIterator"), [node.object]));
  667. path.skip();
  668. } else {
  669. callMethod(path, utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"));
  670. }
  671. } else {
  672. path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"), [path.node.object]));
  673. }
  674. return;
  675. }
  676. }
  677. let resolved = resolve(meta);
  678. if (!resolved) return;
  679. if (canSkipPolyfill(resolved.desc, path)) return;
  680. if (useBabelRuntime && resolved.desc.pure && resolved.desc.pure.slice(-6) === "/index") {
  681. // Remove /index, since it doesn't exist in @babel/runtime-corejs3s
  682. resolved = {
  683. ...resolved,
  684. desc: {
  685. ...resolved.desc,
  686. pure: resolved.desc.pure.slice(0, -6)
  687. }
  688. };
  689. }
  690. if (resolved.kind === "global") {
  691. const id = maybeInjectPure(resolved.desc, resolved.name, utils);
  692. if (id) path.replaceWith(id);
  693. } else if (resolved.kind === "static") {
  694. const id = maybeInjectPure(resolved.desc, resolved.name, utils,
  695. // @ts-expect-error
  696. meta.object);
  697. if (id) path.replaceWith(id);
  698. } else if (resolved.kind === "instance") {
  699. const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils,
  700. // @ts-expect-error
  701. meta.object);
  702. if (!id) return;
  703. const {
  704. node
  705. } = path;
  706. if (t.isCallExpression(path.parent, {
  707. callee: node
  708. })) {
  709. callMethod(path, id);
  710. } else {
  711. path.replaceWith(t.callExpression(id, [node.object]));
  712. }
  713. }
  714. },
  715. visitor: method === "usage-global" && {
  716. // import("foo")
  717. CallExpression(path) {
  718. if (path.get("callee").isImport()) {
  719. const utils = getUtils(path);
  720. if (isWebpack) {
  721. // Webpack uses Promise.all to handle dynamic import.
  722. maybeInjectGlobal(PromiseDependenciesWithIterators, utils);
  723. } else {
  724. maybeInjectGlobal(PromiseDependencies, utils);
  725. }
  726. }
  727. },
  728. // (async function () { }).finally(...)
  729. Function(path) {
  730. if (path.node.async) {
  731. maybeInjectGlobal(PromiseDependencies, getUtils(path));
  732. }
  733. },
  734. // for-of, [a, b] = c
  735. "ForOfStatement|ArrayPattern"(path) {
  736. maybeInjectGlobal(CommonIterators, getUtils(path));
  737. },
  738. // [...spread]
  739. SpreadElement(path) {
  740. if (!path.parentPath.isObjectExpression()) {
  741. maybeInjectGlobal(CommonIterators, getUtils(path));
  742. }
  743. },
  744. // yield*
  745. YieldExpression(path) {
  746. if (path.node.delegate) {
  747. maybeInjectGlobal(CommonIterators, getUtils(path));
  748. }
  749. },
  750. // Decorators metadata
  751. Class(path) {
  752. var _path$node$decorators;
  753. const hasDecorators = ((_path$node$decorators = path.node.decorators) == null ? void 0 : _path$node$decorators.length) || path.node.body.body.some(el => {
  754. var _decorators;
  755. return (_decorators = el.decorators) == null ? void 0 : _decorators.length;
  756. });
  757. if (hasDecorators) {
  758. maybeInjectGlobal(DecoratorMetadataDependencies, getUtils(path));
  759. }
  760. }
  761. }
  762. };
  763. });
  764. export default index;
  765. //# sourceMappingURL=index.mjs.map