mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-21 23:48:05 +00:00
16 lines
523 B
JavaScript
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);
|