Skip to content

Commit

Permalink
[windows] Specify the file:// protocol when importing config on Win…
Browse files Browse the repository at this point in the history
…dows (#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]>
  • Loading branch information
costinsin and conico974 authored Jul 8, 2024
1 parent 001aaa0 commit e2d0c7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/witty-dots-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"open-next": patch
---

[windows] Specify the `file://` protocol when importing config on Windows
4 changes: 3 additions & 1 deletion packages/open-next/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ export async function build(

// Load open-next.config.ts
const tempDir = initTempDir();
const configPath = compileOpenNextConfigNode(
let configPath = compileOpenNextConfigNode(
tempDir,
openNextConfigPath,
nodeExternals,
);
// On Windows, we need to use file:// protocol to load the config file using import()
if (process.platform === "win32") configPath = `file://${configPath}`;
config = (await import(configPath)).default as OpenNextConfig;
validateConfig(config);

Expand Down

0 comments on commit e2d0c7f

Please sign in to comment.