Skip to content

Commit e2d0c7f

Browse files
costinsinconico974
andauthored
[windows] Specify the file:// protocol when importing config on Windows (#460)
* [windows] Specify the `file://` protocol when importing config on Windows On Windows, if the file protocol is not specified when using dynamic imports, the process exits with ERR_UNSUPPORTED_ESM_URL_SCHEME error. Signed-off-by: Costin Sin <[email protected]> * Create witty-dots-film.md --------- Signed-off-by: Costin Sin <[email protected]> Co-authored-by: conico974 <[email protected]>
1 parent 001aaa0 commit e2d0c7f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/witty-dots-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
[windows] Specify the `file://` protocol when importing config on Windows

packages/open-next/src/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ export async function build(
5050

5151
// Load open-next.config.ts
5252
const tempDir = initTempDir();
53-
const configPath = compileOpenNextConfigNode(
53+
let configPath = compileOpenNextConfigNode(
5454
tempDir,
5555
openNextConfigPath,
5656
nodeExternals,
5757
);
58+
// On Windows, we need to use file:// protocol to load the config file using import()
59+
if (process.platform === "win32") configPath = `file://${configPath}`;
5860
config = (await import(configPath)).default as OpenNextConfig;
5961
validateConfig(config);
6062

0 commit comments

Comments
 (0)