source: frontend/node_modules/@babel/plugin-transform-runtime/lib/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 4.8 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _helperPluginUtils = require("@babel/helper-plugin-utils");
8var _helperModuleImports = require("@babel/helper-module-imports");
9var _core = require("@babel/core");
10var _index = require("./get-runtime-path/index.js");
11var _index2 = require("./babel-7/index.cjs");
12var _semver = require("semver");
13var _default = exports.default = (0, _helperPluginUtils.declare)((api, options, dirname) => {
14 api.assertVersion(7);
15 const {
16 version: runtimeVersion = "7.0.0-beta.0",
17 absoluteRuntime = false,
18 moduleName = null
19 } = options;
20 if (typeof absoluteRuntime !== "boolean" && typeof absoluteRuntime !== "string") {
21 throw new Error("The 'absoluteRuntime' option must be undefined, a boolean, or a string.");
22 }
23 if (typeof runtimeVersion !== "string") {
24 throw new Error(`The 'version' option must be a version string.`);
25 }
26 if (moduleName !== null && typeof moduleName !== "string") {
27 throw new Error("The 'moduleName' option must be null or a string.");
28 }
29 var supportsCJSDefault;
30 if (!runtimeVersion) {
31 supportsCJSDefault = true;
32 } else {
33 const normalizedRuntimeVersion = _semver.valid(runtimeVersion) ? `^${runtimeVersion}` : runtimeVersion;
34 supportsCJSDefault = !_semver.intersects(`<7.13.0`, normalizedRuntimeVersion) && !_semver.intersects(`>=8.0.0`, normalizedRuntimeVersion);
35 }
36 if (hasOwnProperty.call(options, "useBuiltIns")) {
37 if (options.useBuiltIns) {
38 throw new Error("The 'useBuiltIns' option has been removed. The @babel/runtime " + "module now uses builtins by default.");
39 } else {
40 throw new Error("The 'useBuiltIns' option has been removed. Use the 'corejs'" + "option to polyfill with `core-js` via @babel/runtime.");
41 }
42 }
43 if (hasOwnProperty.call(options, "polyfill")) {
44 if (options.polyfill === false) {
45 throw new Error("The 'polyfill' option has been removed. The @babel/runtime " + "module now skips polyfilling by default.");
46 } else {
47 throw new Error("The 'polyfill' option has been removed. Use the 'corejs'" + "option to polyfill with `core-js` via @babel/runtime.");
48 }
49 }
50 const {
51 useESModules = false
52 } = options;
53 if (typeof useESModules !== "boolean" && useESModules !== "auto") {
54 throw new Error("The 'useESModules' option must be undefined, or a boolean, or 'auto'.");
55 }
56 var esModules = useESModules === "auto" ? api.caller(caller => !!(caller != null && caller.supportsStaticESM)) : useESModules;
57 var {
58 helpers: useRuntimeHelpers = true
59 } = options;
60 if (typeof useRuntimeHelpers !== "boolean") {
61 throw new Error("The 'helpers' option must be undefined, or a boolean.");
62 }
63 const HEADER_HELPERS = new Set(["interopRequireWildcard", "interopRequireDefault"]);
64 return {
65 name: "transform-runtime",
66 inherits: _index2.createPolyfillPlugins(options, runtimeVersion, absoluteRuntime),
67 pre(file) {
68 if (!useRuntimeHelpers) return;
69 let modulePath;
70 file.set("helperGenerator", name => {
71 var _ref;
72 modulePath != null ? modulePath : modulePath = (0, _index.default)((_ref = moduleName != null ? moduleName : file.get("runtimeHelpersModuleName")) != null ? _ref : "@babel/runtime", dirname, absoluteRuntime);
73 if (!(file.availableHelper != null && file.availableHelper(name, runtimeVersion))) {
74 if (name === "regeneratorRuntime") {
75 return _core.types.arrowFunctionExpression([], _core.types.identifier("regeneratorRuntime"));
76 }
77 if (name === "regenerator" || name === "regeneratorKeys" || name === "regeneratorAsync" || name === "regeneratorAsyncGen") {
78 return _core.types.identifier("__interal_marker_fallback_regenerator__");
79 }
80 return;
81 }
82 const blockHoist = HEADER_HELPERS.has(name) && !(0, _helperModuleImports.isModule)(file.path) ? 4 : undefined;
83 let helperPath = `${modulePath}/helpers/${esModules && file.path.node.sourceType === "module" ? "esm/" + name : name}`;
84 if (absoluteRuntime) helperPath = (0, _index.resolveFSPath)(helperPath);
85 return addDefaultImport(helperPath, name, blockHoist, true);
86 });
87 const cache = new Map();
88 function addDefaultImport(source, nameHint, blockHoist, isHelper = false) {
89 const cacheKey = (0, _helperModuleImports.isModule)(file.path);
90 const key = `${source}:${nameHint}:${cacheKey || ""}`;
91 let cached = cache.get(key);
92 if (cached) {
93 cached = _core.types.cloneNode(cached);
94 } else {
95 cached = (0, _helperModuleImports.addDefault)(file.path, source, {
96 importedInterop: isHelper && supportsCJSDefault ? "compiled" : "uncompiled",
97 nameHint,
98 blockHoist
99 });
100 cache.set(key, cached);
101 }
102 return cached;
103 }
104 }
105 };
106});
107
108//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.