source: trip-planner-front/node_modules/@babel/helper-plugin-utils/lib/index.js@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.declare = declare;
7
8function declare(builder) {
9 return (api, options, dirname) => {
10 var _clonedApi2;
11
12 let clonedApi;
13
14 for (const name of Object.keys(apiPolyfills)) {
15 var _clonedApi;
16
17 if (api[name]) continue;
18 clonedApi = (_clonedApi = clonedApi) != null ? _clonedApi : copyApiObject(api);
19 clonedApi[name] = apiPolyfills[name](clonedApi);
20 }
21
22 return builder((_clonedApi2 = clonedApi) != null ? _clonedApi2 : api, options || {}, dirname);
23 };
24}
25
26const apiPolyfills = {
27 assertVersion: api => range => {
28 throwVersionError(range, api.version);
29 },
30 targets: () => () => {
31 return {};
32 },
33 assumption: () => () => {}
34};
35
36function copyApiObject(api) {
37 let proto = null;
38
39 if (typeof api.version === "string" && /^7\./.test(api.version)) {
40 proto = Object.getPrototypeOf(api);
41
42 if (proto && (!has(proto, "version") || !has(proto, "transform") || !has(proto, "template") || !has(proto, "types"))) {
43 proto = null;
44 }
45 }
46
47 return Object.assign({}, proto, api);
48}
49
50function has(obj, key) {
51 return Object.prototype.hasOwnProperty.call(obj, key);
52}
53
54function throwVersionError(range, version) {
55 if (typeof range === "number") {
56 if (!Number.isInteger(range)) {
57 throw new Error("Expected string or integer value.");
58 }
59
60 range = `^${range}.0.0-0`;
61 }
62
63 if (typeof range !== "string") {
64 throw new Error("Expected string or integer value.");
65 }
66
67 const limit = Error.stackTraceLimit;
68
69 if (typeof limit === "number" && limit < 25) {
70 Error.stackTraceLimit = 25;
71 }
72
73 let err;
74
75 if (version.slice(0, 2) === "7.") {
76 err = new Error(`Requires Babel "^7.0.0-beta.41", but was loaded with "${version}". ` + `You'll need to update your @babel/core version.`);
77 } else {
78 err = new Error(`Requires Babel "${range}", but was loaded with "${version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
79 }
80
81 if (typeof limit === "number") {
82 Error.stackTraceLimit = limit;
83 }
84
85 throw Object.assign(err, {
86 code: "BABEL_VERSION_UNSUPPORTED",
87 version,
88 range
89 });
90}
Note: See TracBrowser for help on using the repository browser.