Skip to content

Commit 538dd86

Browse files
authored
fix: use pathToFileUrl for hooks for Windows ES module support (#8069)
1 parent 5681777 commit 538dd86

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/orange-goats-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix: use `pathToFileUrl` for hooks for Windows ES module support

packages/app-builder-lib/src/platformPackager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { readdir } from "fs/promises"
77
import { Lazy } from "lazy-val"
88
import { Minimatch } from "minimatch"
99
import * as path from "path"
10+
import { pathToFileURL } from "url"
1011
import { AppInfo } from "./appInfo"
1112
import { checkFileInArchive } from "./asar/asarFileChecker"
1213
import { AsarPackager } from "./asar/asarUtil"
@@ -761,7 +762,8 @@ async function resolveModule<T>(type: string | undefined, name: string): Promise
761762
const isModuleType = type === "module"
762763
try {
763764
if (extension === ".mjs" || (extension === ".js" && isModuleType)) {
764-
return await eval("import('" + name + "')")
765+
const fileUrl = pathToFileURL(name).href;
766+
return await eval("import('" + fileUrl + "')")
765767
}
766768
} catch (error) {
767769
log.debug({ moduleName: name }, "Unable to dynamically import hook, falling back to `require`")

0 commit comments

Comments
 (0)