fix: try require first

This commit is contained in:
MARCROCK22 2025-02-18 20:52:06 -04:00
parent e41711770c
commit 61c3c283b9

View File

@ -279,7 +279,12 @@ export const ReplaceRegex = {
};
export async function magicImport(path: string) {
try {
if ('Deno' in globalThis) throw new Error('https://github.com/denoland/deno/issues/26136');
return require(path);
} catch {
return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path);
}
}
export type OnFailCallback = (error: unknown) => any;