UNPKG

@react-gnome/core

Version:

## Getting Started

92 lines (90 loc) 3.21 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/utils/get-polyfills.ts var get_polyfills_exports = {}; __export(get_polyfills_exports, { getCustomPolyfillsImports: () => getCustomPolyfillsImports, getGlobalPolyfillsInmportPaths: () => getGlobalPolyfillsInmportPaths }); module.exports = __toCommonJS(get_polyfills_exports); var getGlobalPolyfillsInmportPaths = (program) => { const polyfills = { ...program.config.polyfills }; const polyFilepaths = []; const soupVersion = (program.config.giVersions?.Soup || "2").split(".")[0]; if (polyfills?.fetch) { polyFilepaths.push(`@react-gnome/core/polyfills/esm/fetch/soup${soupVersion}.mjs`); polyfills.Headers = true; polyfills.URL = true; } if (polyfills?.XMLHttpRequest) { polyFilepaths.push( `@react-gnome/core/polyfills/esm/xml-http-request/soup${soupVersion}.mjs` ); polyfills.URL = true; } if (polyfills?.WebSocket) { polyFilepaths.push( `@react-gnome/core/polyfills/esm/websocket/soup${soupVersion}.mjs` ); } if (polyfills?.URL || polyfills.node?.querystring) { polyfills.Buffer = true; } if (polyfills?.Buffer) { polyFilepaths.push("@react-gnome/core/polyfills/esm/buffer.mjs"); } if (polyfills?.URL) { polyFilepaths.push("@react-gnome/core/polyfills/esm/url.mjs"); } if (polyfills?.Headers) { polyFilepaths.push("@react-gnome/core/polyfills/esm/headers.mjs"); } if (polyfills?.Blob) { polyFilepaths.push("@react-gnome/core/polyfills/esm/blob.mjs"); } if (polyfills?.FormData) { polyFilepaths.push("@react-gnome/core/polyfills/esm/form-data.mjs"); } if (polyfills?.base64) { polyFilepaths.push("@react-gnome/core/polyfills/esm/base64.mjs"); } if (polyfills?.AbortController) { polyFilepaths.push( "@react-gnome/core/polyfills/esm/abort-controller.mjs" ); } if (polyfills?.queueMicrotask) { polyFilepaths.push("@react-gnome/core/polyfills/esm/queue-microtask.mjs"); } return polyFilepaths; }; var getCustomPolyfillsImports = (program) => { const codeLines = []; if (program.config.customPolyfills) { for (const [idx, customPoly] of program.config.customPolyfills.entries()) { if (!customPoly.importName) { codeLines.push( `import cpolly_${idx} from ${JSON.stringify(customPoly.filepath)};` ); codeLines.push(`registerPolyfills.fromModule(cpolly_${idx});`); } } } return codeLines; };