Skip to content

Commit

Permalink
fix: try require first
Browse files Browse the repository at this point in the history
  • Loading branch information
MARCROCK22 committed Feb 19, 2025
1 parent e417117 commit 61c3c28
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/common/it/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ export const ReplaceRegex = {
};

export async function magicImport(path: string) {
return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path);
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;
Expand Down

0 comments on commit 61c3c28

Please sign in to comment.