Files
pezkuwi-common/packages/x-fetch/node.js
T

16 lines
523 B
JavaScript

import { extractGlobal } from '@pezkuwi/x-global';
export { packageInfo } from './packageInfo.js';
const importFetch = import('node-fetch').catch(() => null);
let modFn = null;
async function nodeFetch(...args) {
if (!modFn) {
const mod = await importFetch;
if (!mod?.default) {
throw new Error('Unable to import node-fetch in this environment');
}
modFn = mod.default;
}
return modFn(...args);
}
export const fetch = /*#__PURE__*/ extractGlobal('fetch', nodeFetch);