source: trip-planner-front/node_modules/babel-plugin-polyfill-corejs3/esm/index.mjs

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 28.0 KB
Line 
1import corejs3Polyfills from '../core-js-compat/data.js';
2import getModulesListForTargetVersion from '../core-js-compat/get-modules-list-for-target-version.js';
3import * as babel from '@babel/core';
4import corejsEntries from '../core-js-compat/entries.js';
5import defineProvider from '@babel/helper-define-polyfill-provider';
6
7var corejs3ShippedProposalsList = new Set(["esnext.global-this", "esnext.string.match-all"]);
8
9const polyfillsOrder = {};
10Object.keys(corejs3Polyfills).forEach((name, index) => {
11 polyfillsOrder[name] = index;
12});
13
14const define = (pure, global, name = global[0], exclude) => {
15 return {
16 name,
17 pure,
18 global: global.sort((a, b) => polyfillsOrder[a] - polyfillsOrder[b]),
19 exclude
20 };
21};
22
23const typed = name => define(null, [name, ...TypedArrayDependencies]);
24
25const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
26const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
27const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
28const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
29const TypedArrayDependencies = ["es.typed-array.copy-within", "es.typed-array.every", "es.typed-array.fill", "es.typed-array.filter", "es.typed-array.find", "es.typed-array.find-index", "es.typed-array.for-each", "es.typed-array.includes", "es.typed-array.index-of", "es.typed-array.iterator", "es.typed-array.join", "es.typed-array.last-index-of", "es.typed-array.map", "es.typed-array.reduce", "es.typed-array.reduce-right", "es.typed-array.reverse", "es.typed-array.set", "es.typed-array.slice", "es.typed-array.some", "es.typed-array.sort", "es.typed-array.subarray", "es.typed-array.to-locale-string", "es.typed-array.to-string", "es.object.to-string", "es.array.iterator", "es.array-buffer.slice"];
30const TypedArrayStaticMethods = {
31 from: define(null, ["es.typed-array.from"]),
32 of: define(null, ["es.typed-array.of"])
33};
34const PromiseDependencies = ["es.promise", "es.object.to-string"];
35const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
36const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
37const MapDependencies = ["es.map", "esnext.map.delete-all", "esnext.map.every", "esnext.map.filter", "esnext.map.find", "esnext.map.find-key", "esnext.map.includes", "esnext.map.key-of", "esnext.map.map-keys", "esnext.map.map-values", "esnext.map.merge", "esnext.map.reduce", "esnext.map.some", "esnext.map.update", ...CommonIteratorsWithTag];
38const SetDependencies = ["es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.is-disjoint-from", "esnext.set.is-subset-of", "esnext.set.is-superset-of", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.union", ...CommonIteratorsWithTag];
39const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", ...CommonIteratorsWithTag];
40const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
41const URLSearchParamsDependencies = ["web.url-search-params", ...CommonIteratorsWithTag];
42const BuiltIns = {
43 AggregateError: define("aggregate-error", ["es.aggregate-error", ...CommonIterators]),
44 ArrayBuffer: define(null, ["es.array-buffer.constructor", "es.array-buffer.slice", "es.object.to-string"]),
45 DataView: define(null, ["es.data-view", "es.array-buffer.slice", "es.object.to-string"]),
46 Date: define(null, ["es.date.to-string"]),
47 Float32Array: typed("es.typed-array.float32-array"),
48 Float64Array: typed("es.typed-array.float64-array"),
49 Int8Array: typed("es.typed-array.int8-array"),
50 Int16Array: typed("es.typed-array.int16-array"),
51 Int32Array: typed("es.typed-array.int32-array"),
52 Uint8Array: typed("es.typed-array.uint8-array"),
53 Uint8ClampedArray: typed("es.typed-array.uint8-clamped-array"),
54 Uint16Array: typed("es.typed-array.uint16-array"),
55 Uint32Array: typed("es.typed-array.uint32-array"),
56 Map: define("map/index", MapDependencies),
57 Number: define(null, ["es.number.constructor"]),
58 Observable: define("observable/index", ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag]),
59 Promise: define("promise/index", PromiseDependencies),
60 RegExp: define(null, ["es.regexp.constructor", "es.regexp.exec", "es.regexp.to-string"]),
61 Set: define("set/index", SetDependencies),
62 Symbol: define("symbol/index", SymbolDependencies),
63 URL: define("url/index", ["web.url", ...URLSearchParamsDependencies]),
64 URLSearchParams: define("url-search-params/index", URLSearchParamsDependencies),
65 WeakMap: define("weak-map/index", WeakMapDependencies),
66 WeakSet: define("weak-set/index", WeakSetDependencies),
67 clearImmediate: define("clear-immediate", ["web.immediate"]),
68 compositeKey: define("composite-key", ["esnext.composite-key"]),
69 compositeSymbol: define("composite-symbol", ["esnext.composite-symbol"]),
70 fetch: define(null, PromiseDependencies),
71 globalThis: define("global-this", ["es.global-this"]),
72 parseFloat: define("parse-float", ["es.parse-float"]),
73 parseInt: define("parse-int", ["es.parse-int"]),
74 queueMicrotask: define("queue-microtask", ["web.queue-microtask"]),
75 setImmediate: define("set-immediate", ["web.immediate"]),
76 setInterval: define("set-interval", ["web.timers"]),
77 setTimeout: define("set-timeout", ["web.timers"])
78};
79const StaticProperties = {
80 Array: {
81 from: define("array/from", ["es.array.from", "es.string.iterator"]),
82 isArray: define("array/is-array", ["es.array.is-array"]),
83 of: define("array/of", ["es.array.of"])
84 },
85 ArrayBuffer: {
86 isView: define(null, ["es.array-buffer.is-view"])
87 },
88 Date: {
89 now: define("date/now", ["es.date.now"])
90 },
91 JSON: {
92 stringify: define("json/stringify", [], "es.symbol")
93 },
94 Math: {
95 DEG_PER_RAD: define("math/deg-per-rad", ["esnext.math.deg-per-rad"]),
96 RAD_PER_DEG: define("math/rad-per-deg", ["esnext.math.rad-per-deg"]),
97 acosh: define("math/acosh", ["es.math.acosh"]),
98 asinh: define("math/asinh", ["es.math.asinh"]),
99 atanh: define("math/atanh", ["es.math.atanh"]),
100 cbrt: define("math/cbrt", ["es.math.cbrt"]),
101 clamp: define("math/clamp", ["esnext.math.clamp"]),
102 clz32: define("math/clz32", ["es.math.clz32"]),
103 cosh: define("math/cosh", ["es.math.cosh"]),
104 degrees: define("math/degrees", ["esnext.math.degrees"]),
105 expm1: define("math/expm1", ["es.math.expm1"]),
106 fround: define("math/fround", ["es.math.fround"]),
107 fscale: define("math/fscale", ["esnext.math.fscale"]),
108 hypot: define("math/hypot", ["es.math.hypot"]),
109 iaddh: define("math/iaddh", ["esnext.math.iaddh"]),
110 imul: define("math/imul", ["es.math.imul"]),
111 imulh: define("math/imulh", ["esnext.math.imulh"]),
112 isubh: define("math/isubh", ["esnext.math.isubh"]),
113 log10: define("math/log10", ["es.math.log10"]),
114 log1p: define("math/log1p", ["es.math.log1p"]),
115 log2: define("math/log2", ["es.math.log2"]),
116 radians: define("math/radians", ["esnext.math.radians"]),
117 scale: define("math/scale", ["esnext.math.scale"]),
118 seededPRNG: define("math/seeded-prng", ["esnext.math.seeded-prng"]),
119 sign: define("math/sign", ["es.math.sign"]),
120 signbit: define("math/signbit", ["esnext.math.signbit"]),
121 sinh: define("math/sinh", ["es.math.sinh"]),
122 tanh: define("math/tanh", ["es.math.tanh"]),
123 trunc: define("math/trunc", ["es.math.trunc"]),
124 umulh: define("math/umulh", ["esnext.math.umulh"])
125 },
126 Map: {
127 from: define(null, ["esnext.map.from", ...MapDependencies]),
128 groupBy: define(null, ["esnext.map.group-by", ...MapDependencies]),
129 keyBy: define(null, ["esnext.map.key-by", ...MapDependencies]),
130 of: define(null, ["esnext.map.of", ...MapDependencies])
131 },
132 Number: {
133 EPSILON: define("number/epsilon", ["es.number.epsilon"]),
134 MAX_SAFE_INTEGER: define("number/max-safe-integer", ["es.number.max-safe-integer"]),
135 MIN_SAFE_INTEGER: define("number/min-safe-integer", ["es.number.min-safe-integer"]),
136 fromString: define("number/from-string", ["esnext.number.from-string"]),
137 isFinite: define("number/is-finite", ["es.number.is-finite"]),
138 isInteger: define("number/is-integer", ["es.number.is-integer"]),
139 isNaN: define("number/is-nan", ["es.number.is-nan"]),
140 isSafeInteger: define("number/is-safe-integer", ["es.number.is-safe-integer"]),
141 parseFloat: define("number/parse-float", ["es.number.parse-float"]),
142 parseInt: define("number/parse-int", ["es.number.parse-int"])
143 },
144 Object: {
145 assign: define("object/assign", ["es.object.assign"]),
146 create: define("object/create", ["es.object.create"]),
147 defineProperties: define("object/define-properties", ["es.object.define-properties"]),
148 defineProperty: define("object/define-property", ["es.object.define-property"]),
149 entries: define("object/entries", ["es.object.entries"]),
150 freeze: define("object/freeze", ["es.object.freeze"]),
151 fromEntries: define("object/from-entries", ["es.object.from-entries", "es.array.iterator"]),
152 getOwnPropertyDescriptor: define("object/get-own-property-descriptor", ["es.object.get-own-property-descriptor"]),
153 getOwnPropertyDescriptors: define("object/get-own-property-descriptors", ["es.object.get-own-property-descriptors"]),
154 getOwnPropertyNames: define("object/get-own-property-names", ["es.object.get-own-property-names"]),
155 getOwnPropertySymbols: define("object/get-own-property-symbols", ["es.symbol"]),
156 getPrototypeOf: define("object/get-prototype-of", ["es.object.get-prototype-of"]),
157 hasOwn: define("object/has-own", ["esnext.object.has-own"]),
158 is: define("object/is", ["es.object.is"]),
159 isExtensible: define("object/is-extensible", ["es.object.is-extensible"]),
160 isFrozen: define("object/is-frozen", ["es.object.is-frozen"]),
161 isSealed: define("object/is-sealed", ["es.object.is-sealed"]),
162 keys: define("object/keys", ["es.object.keys"]),
163 preventExtensions: define("object/prevent-extensions", ["es.object.prevent-extensions"]),
164 seal: define("object/seal", ["es.object.seal"]),
165 setPrototypeOf: define("object/set-prototype-of", ["es.object.set-prototype-of"]),
166 values: define("object/values", ["es.object.values"])
167 },
168 Promise: {
169 all: define(null, PromiseDependenciesWithIterators),
170 allSettled: define(null, ["es.promise.all-settled", ...PromiseDependenciesWithIterators]),
171 any: define(null, ["es.promise.any", ...PromiseDependenciesWithIterators]),
172 race: define(null, PromiseDependenciesWithIterators),
173 try: define(null, ["esnext.promise.try", ...PromiseDependenciesWithIterators])
174 },
175 Reflect: {
176 apply: define("reflect/apply", ["es.reflect.apply"]),
177 construct: define("reflect/construct", ["es.reflect.construct"]),
178 defineMetadata: define("reflect/define-metadata", ["esnext.reflect.define-metadata"]),
179 defineProperty: define("reflect/define-property", ["es.reflect.define-property"]),
180 deleteMetadata: define("reflect/delete-metadata", ["esnext.reflect.delete-metadata"]),
181 deleteProperty: define("reflect/delete-property", ["es.reflect.delete-property"]),
182 get: define("reflect/get", ["es.reflect.get"]),
183 getMetadata: define("reflect/get-metadata", ["esnext.reflect.get-metadata"]),
184 getMetadataKeys: define("reflect/get-metadata-keys", ["esnext.reflect.get-metadata-keys"]),
185 getOwnMetadata: define("reflect/get-own-metadata", ["esnext.reflect.get-own-metadata"]),
186 getOwnMetadataKeys: define("reflect/get-own-metadata-keys", ["esnext.reflect.get-own-metadata-keys"]),
187 getOwnPropertyDescriptor: define("reflect/get-own-property-descriptor", ["es.reflect.get-own-property-descriptor"]),
188 getPrototypeOf: define("reflect/get-prototype-of", ["es.reflect.get-prototype-of"]),
189 has: define("reflect/has", ["es.reflect.has"]),
190 hasMetadata: define("reflect/has-metadata", ["esnext.reflect.has-metadata"]),
191 hasOwnMetadata: define("reflect/has-own-metadata", ["esnext.reflect.has-own-metadata"]),
192 isExtensible: define("reflect/is-extensible", ["es.reflect.is-extensible"]),
193 metadata: define("reflect/metadata", ["esnext.reflect.metadata"]),
194 ownKeys: define("reflect/own-keys", ["es.reflect.own-keys"]),
195 preventExtensions: define("reflect/prevent-extensions", ["es.reflect.prevent-extensions"]),
196 set: define("reflect/set", ["es.reflect.set"]),
197 setPrototypeOf: define("reflect/set-prototype-of", ["es.reflect.set-prototype-of"])
198 },
199 Set: {
200 from: define(null, ["esnext.set.from", ...SetDependencies]),
201 of: define(null, ["esnext.set.of", ...SetDependencies])
202 },
203 String: {
204 fromCodePoint: define("string/from-code-point", ["es.string.from-code-point"]),
205 raw: define("string/raw", ["es.string.raw"])
206 },
207 Symbol: {
208 asyncIterator: define("symbol/async-iterator", ["es.symbol.async-iterator"]),
209 dispose: define("symbol/dispose", ["esnext.symbol.dispose"]),
210 for: define("symbol/for", [], "es.symbol"),
211 hasInstance: define("symbol/has-instance", ["es.symbol.has-instance", "es.function.has-instance"]),
212 isConcatSpreadable: define("symbol/is-concat-spreadable", ["es.symbol.is-concat-spreadable", "es.array.concat"]),
213 iterator: define("symbol/iterator", ["es.symbol.iterator", ...CommonIteratorsWithTag]),
214 keyFor: define("symbol/key-for", [], "es.symbol"),
215 match: define("symbol/match", ["es.symbol.match", "es.string.match"]),
216 observable: define("symbol/observable", ["esnext.symbol.observable"]),
217 patternMatch: define("symbol/pattern-match", ["esnext.symbol.pattern-match"]),
218 replace: define("symbol/replace", ["es.symbol.replace", "es.string.replace"]),
219 search: define("symbol/search", ["es.symbol.search", "es.string.search"]),
220 species: define("symbol/species", ["es.symbol.species", "es.array.species"]),
221 split: define("symbol/split", ["es.symbol.split", "es.string.split"]),
222 toPrimitive: define("symbol/to-primitive", ["es.symbol.to-primitive", "es.date.to-primitive"]),
223 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"]),
224 unscopables: define("symbol/unscopables", ["es.symbol.unscopables"])
225 },
226 WeakMap: {
227 from: define(null, ["esnext.weak-map.from", ...WeakMapDependencies]),
228 of: define(null, ["esnext.weak-map.of", ...WeakMapDependencies])
229 },
230 WeakSet: {
231 from: define(null, ["esnext.weak-set.from", ...WeakSetDependencies]),
232 of: define(null, ["esnext.weak-set.of", ...WeakSetDependencies])
233 },
234 Int8Array: TypedArrayStaticMethods,
235 Uint8Array: TypedArrayStaticMethods,
236 Uint8ClampedArray: TypedArrayStaticMethods,
237 Int16Array: TypedArrayStaticMethods,
238 Uint16Array: TypedArrayStaticMethods,
239 Int32Array: TypedArrayStaticMethods,
240 Uint32Array: TypedArrayStaticMethods,
241 Float32Array: TypedArrayStaticMethods,
242 Float64Array: TypedArrayStaticMethods
243};
244const InstanceProperties = {
245 at: define("instance/at", ["esnext.string.at", "esnext.array.at", "esnext.typed-array.at"]),
246 anchor: define(null, ["es.string.anchor"]),
247 big: define(null, ["es.string.big"]),
248 bind: define("instance/bind", ["es.function.bind"]),
249 blink: define(null, ["es.string.blink"]),
250 bold: define(null, ["es.string.bold"]),
251 codePointAt: define("instance/code-point-at", ["es.string.code-point-at"]),
252 codePoints: define("instance/code-points", ["esnext.string.code-points"]),
253 concat: define("instance/concat", ["es.array.concat"], undefined, ["String"]),
254 copyWithin: define("instance/copy-within", ["es.array.copy-within"]),
255 description: define(null, ["es.symbol", "es.symbol.description"]),
256 endsWith: define("instance/ends-with", ["es.string.ends-with"]),
257 entries: define("instance/entries", ArrayNatureIteratorsWithTag),
258 every: define("instance/every", ["es.array.every"]),
259 exec: define(null, ["es.regexp.exec"]),
260 fill: define("instance/fill", ["es.array.fill"]),
261 filter: define("instance/filter", ["es.array.filter"]),
262 finally: define(null, ["es.promise.finally", ...PromiseDependencies]),
263 find: define("instance/find", ["es.array.find"]),
264 findIndex: define("instance/find-index", ["es.array.find-index"]),
265 findLast: define("instance/find-last", ["esnext.array.find-last"]),
266 findLastIndex: define("instance/find-last-index", ["esnext.array.find-last-index"]),
267 fixed: define(null, ["es.string.fixed"]),
268 flags: define("instance/flags", ["es.regexp.flags"]),
269 flatMap: define("instance/flat-map", ["es.array.flat-map", "es.array.unscopables.flat-map"]),
270 flat: define("instance/flat", ["es.array.flat"]),
271 fontcolor: define(null, ["es.string.fontcolor"]),
272 fontsize: define(null, ["es.string.fontsize"]),
273 forEach: define("instance/for-each", ["es.array.for-each", "web.dom-collections.for-each"]),
274 includes: define("instance/includes", ["es.array.includes", "es.string.includes"]),
275 indexOf: define("instance/index-of", ["es.array.index-of"]),
276 italic: define(null, ["es.string.italics"]),
277 join: define(null, ["es.array.join"]),
278 keys: define("instance/keys", ArrayNatureIteratorsWithTag),
279 lastIndex: define(null, ["esnext.array.last-index"]),
280 lastIndexOf: define("instance/last-index-of", ["es.array.last-index-of"]),
281 lastItem: define(null, ["esnext.array.last-item"]),
282 link: define(null, ["es.string.link"]),
283 map: define("instance/map", ["es.array.map"]),
284 match: define(null, ["es.string.match", "es.regexp.exec"]),
285 matchAll: define("instance/match-all", ["es.string.match-all"]),
286 name: define(null, ["es.function.name"]),
287 padEnd: define("instance/pad-end", ["es.string.pad-end"]),
288 padStart: define("instance/pad-start", ["es.string.pad-start"]),
289 reduce: define("instance/reduce", ["es.array.reduce"]),
290 reduceRight: define("instance/reduce-right", ["es.array.reduce-right"]),
291 repeat: define("instance/repeat", ["es.string.repeat"]),
292 replace: define(null, ["es.string.replace", "es.regexp.exec"]),
293 replaceAll: define("instance/replace-all", ["es.string.replace-all"]),
294 reverse: define("instance/reverse", ["es.array.reverse"]),
295 search: define(null, ["es.string.search", "es.regexp.exec"]),
296 slice: define("instance/slice", ["es.array.slice"]),
297 small: define(null, ["es.string.small"]),
298 some: define("instance/some", ["es.array.some"]),
299 sort: define("instance/sort", ["es.array.sort"]),
300 splice: define("instance/splice", ["es.array.splice"]),
301 split: define(null, ["es.string.split", "es.regexp.exec"]),
302 startsWith: define("instance/starts-with", ["es.string.starts-with"]),
303 strike: define(null, ["es.string.strike"]),
304 sub: define(null, ["es.string.sub"]),
305 sup: define(null, ["es.string.sup"]),
306 toFixed: define(null, ["es.number.to-fixed"]),
307 toISOString: define(null, ["es.date.to-iso-string"]),
308 toJSON: define(null, ["es.date.to-json", "web.url.to-json"]),
309 toPrecision: define(null, ["es.number.to-precision"]),
310 toString: define(null, ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"]),
311 trim: define("instance/trim", ["es.string.trim"]),
312 trimEnd: define("instance/trim-end", ["es.string.trim-end"]),
313 trimLeft: define("instance/trim-left", ["es.string.trim-start"]),
314 trimRight: define("instance/trim-right", ["es.string.trim-end"]),
315 trimStart: define("instance/trim-start", ["es.string.trim-start"]),
316 values: define("instance/values", ArrayNatureIteratorsWithTag),
317 __defineGetter__: define(null, ["es.object.define-getter"]),
318 __defineSetter__: define(null, ["es.object.define-setter"]),
319 __lookupGetter__: define(null, ["es.object.lookup-getter"]),
320 __lookupSetter__: define(null, ["es.object.lookup-setter"])
321};
322const CommonInstanceDependencies = new Set(["es.object.to-string", "es.object.define-getter", "es.object.define-setter", "es.object.lookup-getter", "es.object.lookup-setter", "es.regexp.exec"]);
323
324const {
325 types: t$1
326} = babel.default || babel;
327function callMethod(path, id) {
328 const {
329 object
330 } = path.node;
331 let context1, context2;
332
333 if (t$1.isIdentifier(object)) {
334 context1 = object;
335 context2 = t$1.cloneNode(object);
336 } else {
337 context1 = path.scope.generateDeclaredUidIdentifier("context");
338 context2 = t$1.assignmentExpression("=", t$1.cloneNode(context1), object);
339 }
340
341 path.replaceWith(t$1.memberExpression(t$1.callExpression(id, [context2]), t$1.identifier("call")));
342 path.parentPath.unshiftContainer("arguments", context1);
343}
344function isCoreJSSource(source) {
345 if (typeof source === "string") {
346 source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
347 }
348
349 return hasOwnProperty.call(corejsEntries, source) && corejsEntries[source];
350}
351function coreJSModule(name) {
352 return `core-js/modules/${name}.js`;
353}
354function coreJSPureHelper(name, useBabelRuntime, ext) {
355 return useBabelRuntime ? `${useBabelRuntime}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
356}
357
358const {
359 types: t
360} = babel.default || babel;
361const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
362
363const esnextFallback = (name, cb) => {
364 if (cb(name)) return true;
365 if (!name.startsWith("es.")) return false;
366 const fallback = `esnext.${name.slice(3)}`;
367 if (!corejs3Polyfills[fallback]) return false;
368 return cb(fallback);
369};
370
371var index = defineProvider(function ({
372 getUtils,
373 method,
374 shouldInjectPolyfill,
375 createMetaResolver,
376 debug,
377 babel
378}, {
379 version = 3,
380 proposals,
381 shippedProposals,
382 [runtimeCompat]: {
383 useBabelRuntime,
384 ext = ".js"
385 } = {}
386}) {
387 const isWebpack = babel.caller(caller => caller?.name === "babel-loader");
388 const resolve = createMetaResolver({
389 global: BuiltIns,
390 static: StaticProperties,
391 instance: InstanceProperties
392 });
393 const available = new Set(getModulesListForTargetVersion(version));
394
395 function getCoreJSPureBase(useProposalBase) {
396 return useBabelRuntime ? useProposalBase ? `${useBabelRuntime}/core-js` : `${useBabelRuntime}/core-js-stable` : useProposalBase ? "core-js-pure/features" : "core-js-pure/stable";
397 }
398
399 function maybeInjectGlobalImpl(name, utils) {
400 if (shouldInjectPolyfill(name)) {
401 debug(name);
402 utils.injectGlobalImport(coreJSModule(name));
403 return true;
404 }
405
406 return false;
407 }
408
409 function maybeInjectGlobal(names, utils, fallback = true) {
410 for (const name of names) {
411 if (fallback) {
412 esnextFallback(name, name => maybeInjectGlobalImpl(name, utils));
413 } else {
414 maybeInjectGlobalImpl(name, utils);
415 }
416 }
417 }
418
419 function maybeInjectPure(desc, hint, utils, object) {
420 if (desc.pure && !(object && desc.exclude && desc.exclude.includes(object)) && esnextFallback(desc.name, shouldInjectPolyfill)) {
421 const {
422 name
423 } = desc;
424 let useProposalBase = false;
425
426 if (proposals || shippedProposals && name.startsWith("esnext.")) {
427 useProposalBase = true;
428 } else if (name.startsWith("es.") && !available.has(name)) {
429 useProposalBase = true;
430 }
431
432 const coreJSPureBase = getCoreJSPureBase(useProposalBase);
433 return utils.injectDefaultImport( // $FlowIgnore, we already guard desc.pure
434 `${coreJSPureBase}/${desc.pure}${ext}`, hint);
435 }
436 }
437
438 function isFeatureStable(name) {
439 if (name.startsWith("esnext.")) {
440 const esName = `es.${name.slice(7)}`; // If its imaginative esName is not in latest compat data, it means
441 // the proposal is not stage 4
442
443 return esName in corejs3Polyfills;
444 }
445
446 return true;
447 }
448
449 return {
450 name: "corejs3",
451 polyfills: corejs3Polyfills,
452
453 filterPolyfills(name) {
454 if (!available.has(name)) return false;
455 if (proposals || method === "entry-global") return true;
456
457 if (shippedProposals && corejs3ShippedProposalsList.has(name)) {
458 return true;
459 }
460
461 return isFeatureStable(name);
462 },
463
464 entryGlobal(meta, utils, path) {
465 if (meta.kind !== "import") return;
466 const modules = isCoreJSSource(meta.source);
467 if (!modules) return;
468
469 if (modules.length === 1 && meta.source === coreJSModule(modules[0]) && shouldInjectPolyfill(modules[0])) {
470 // Avoid infinite loop: do not replace imports with a new copy of
471 // themselves.
472 debug(null);
473 return;
474 }
475
476 maybeInjectGlobal(modules, utils, false);
477 path.remove();
478 },
479
480 usageGlobal(meta, utils) {
481 const resolved = resolve(meta);
482 if (!resolved) return;
483 let deps = resolved.desc.global;
484
485 if (resolved.kind !== "global" && meta.object && meta.placement === "prototype") {
486 const low = meta.object.toLowerCase();
487 deps = deps.filter(m => m.includes(low) || CommonInstanceDependencies.has(m));
488 }
489
490 maybeInjectGlobal(deps, utils);
491 },
492
493 usagePure(meta, utils, path) {
494 if (meta.kind === "in") {
495 if (meta.key === "Symbol.iterator") {
496 path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("is-iterable", useBabelRuntime, ext), "isIterable"), [path.node.right]));
497 }
498
499 return;
500 }
501
502 if (path.parentPath.isUnaryExpression({
503 operator: "delete"
504 })) return;
505 let isCall;
506
507 if (meta.kind === "property") {
508 // We can't compile destructuring.
509 if (!path.isMemberExpression()) return;
510 if (!path.isReferenced()) return;
511 isCall = path.parentPath.isCallExpression({
512 callee: path.node
513 });
514
515 if (meta.key === "Symbol.iterator") {
516 if (!shouldInjectPolyfill("es.symbol.iterator")) return;
517
518 if (isCall) {
519 if (path.parent.arguments.length === 0) {
520 path.parentPath.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator", useBabelRuntime, ext), "getIterator"), [path.node.object]));
521 path.skip();
522 } else {
523 callMethod(path, utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"));
524 }
525 } else {
526 path.replaceWith(t.callExpression(utils.injectDefaultImport(coreJSPureHelper("get-iterator-method", useBabelRuntime, ext), "getIteratorMethod"), [path.node.object]));
527 }
528
529 return;
530 }
531 }
532
533 let resolved = resolve(meta);
534 if (!resolved) return;
535
536 if (useBabelRuntime && resolved.desc.pure && resolved.desc.pure.slice(-6) === "/index") {
537 // Remove /index, since it doesn't exist in @babel/runtime-corejs3s
538 resolved = { ...resolved,
539 desc: { ...resolved.desc,
540 pure: resolved.desc.pure.slice(0, -6)
541 }
542 };
543 }
544
545 if (resolved.kind === "global") {
546 const id = maybeInjectPure(resolved.desc, resolved.name, utils);
547 if (id) path.replaceWith(id);
548 } else if (resolved.kind === "static") {
549 const id = maybeInjectPure(resolved.desc, resolved.name, utils, // $FlowIgnore
550 meta.object);
551 if (id) path.replaceWith(id);
552 } else if (resolved.kind === "instance") {
553 const id = maybeInjectPure(resolved.desc, `${resolved.name}InstanceProperty`, utils, // $FlowIgnore
554 meta.object);
555 if (!id) return;
556
557 if (isCall) {
558 callMethod(path, id);
559 } else {
560 path.replaceWith(t.callExpression(id, [path.node.object]));
561 }
562 }
563 },
564
565 visitor: method === "usage-global" && {
566 // import("foo")
567 CallExpression(path) {
568 if (path.get("callee").isImport()) {
569 const utils = getUtils(path);
570
571 if (isWebpack) {
572 // Webpack uses Promise.all to handle dynamic import.
573 maybeInjectGlobal(PromiseDependenciesWithIterators, utils);
574 } else {
575 maybeInjectGlobal(PromiseDependencies, utils);
576 }
577 }
578 },
579
580 // (async function () { }).finally(...)
581 Function(path) {
582 if (path.node.async) {
583 maybeInjectGlobal(PromiseDependencies, getUtils(path));
584 }
585 },
586
587 // for-of, [a, b] = c
588 "ForOfStatement|ArrayPattern"(path) {
589 maybeInjectGlobal(CommonIterators, getUtils(path));
590 },
591
592 // [...spread]
593 SpreadElement(path) {
594 if (!path.parentPath.isObjectExpression()) {
595 maybeInjectGlobal(CommonIterators, getUtils(path));
596 }
597 },
598
599 // yield*
600 YieldExpression(path) {
601 if (path.node.delegate) {
602 maybeInjectGlobal(CommonIterators, getUtils(path));
603 }
604 }
605
606 }
607 };
608});
609
610export default index;
611//# sourceMappingURL=index.mjs.map
Note: See TracBrowser for help on using the repository browser.