fix: Fix import error on Windows (ERR_UNSUPPORTED_ESM_URL_SCHEME) (#27519)

This commit is contained in:
Ilya Kirov
2025-05-26 20:32:45 +02:00
committed by GitHub
parent 02b08834e4
commit ed03c40dad
+2 -1
View File
@@ -218,7 +218,8 @@ export default abstract class ExternalJSExtension<M> 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);