1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.callMethod = callMethod;
|
---|
5 | exports.isCoreJSSource = isCoreJSSource;
|
---|
6 | exports.coreJSModule = coreJSModule;
|
---|
7 | exports.coreJSPureHelper = coreJSPureHelper;
|
---|
8 |
|
---|
9 | var babel = _interopRequireWildcard(require("@babel/core"));
|
---|
10 |
|
---|
11 | var _entries = _interopRequireDefault(require("../core-js-compat/entries.js"));
|
---|
12 |
|
---|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
14 |
|
---|
15 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
---|
16 |
|
---|
17 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
---|
18 |
|
---|
19 | const {
|
---|
20 | types: t
|
---|
21 | } = babel.default || babel;
|
---|
22 |
|
---|
23 | function callMethod(path, id) {
|
---|
24 | const {
|
---|
25 | object
|
---|
26 | } = path.node;
|
---|
27 | let context1, context2;
|
---|
28 |
|
---|
29 | if (t.isIdentifier(object)) {
|
---|
30 | context1 = object;
|
---|
31 | context2 = t.cloneNode(object);
|
---|
32 | } else {
|
---|
33 | context1 = path.scope.generateDeclaredUidIdentifier("context");
|
---|
34 | context2 = t.assignmentExpression("=", t.cloneNode(context1), object);
|
---|
35 | }
|
---|
36 |
|
---|
37 | path.replaceWith(t.memberExpression(t.callExpression(id, [context2]), t.identifier("call")));
|
---|
38 | path.parentPath.unshiftContainer("arguments", context1);
|
---|
39 | }
|
---|
40 |
|
---|
41 | function isCoreJSSource(source) {
|
---|
42 | if (typeof source === "string") {
|
---|
43 | source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
|
---|
44 | }
|
---|
45 |
|
---|
46 | return hasOwnProperty.call(_entries.default, source) && _entries.default[source];
|
---|
47 | }
|
---|
48 |
|
---|
49 | function coreJSModule(name) {
|
---|
50 | return `core-js/modules/${name}.js`;
|
---|
51 | }
|
---|
52 |
|
---|
53 | function coreJSPureHelper(name, useBabelRuntime, ext) {
|
---|
54 | return useBabelRuntime ? `${useBabelRuntime}/core-js/${name}${ext}` : `core-js-pure/features/${name}.js`;
|
---|
55 | } |
---|