UNPKG

@react-gnome/core

Version:

## Getting Started

71 lines (70 loc) 2.22 kB
// src/utils/get-polyfills.ts 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; }; export { getCustomPolyfillsImports, getGlobalPolyfillsInmportPaths };