From ed03c40dad1a8722b24e84f4ed8613b0e37a99ea Mon Sep 17 00:00:00 2001 From: Ilya Kirov Date: Mon, 26 May 2025 21:32:45 +0300 Subject: [PATCH] fix: Fix import error on Windows (ERR_UNSUPPORTED_ESM_URL_SCHEME) (#27519) --- lib/extension/externalJS.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/extension/externalJS.ts b/lib/extension/externalJS.ts index bf43951a2..66212bec2 100644 --- a/lib/extension/externalJS.ts +++ b/lib/extension/externalJS.ts @@ -218,7 +218,8 @@ export default abstract class ExternalJSExtension extends Extension { fs.copyFileSync(file, tmpFile); try { // Do `replaceAll("\\", "/")` to prevent issues on Windows - const mod = await import(tmpFile.replaceAll("\\", "/")); + /* v8 ignore next */ + const mod = await import(os.platform() === "win32" ? `file:///${tmpFile.replaceAll("\\", "/")}` : tmpFile); return mod; } finally { fs.rmSync(tmpFile);