@@ -15,13 +15,14 @@ import { validateConfig } from "./validateConfig.js";
1515 *
1616 * @param baseDir Directory where to look for the configuration.
1717 * @param openNextConfigPath Override the default configuration when provided. Relative to baseDir.
18- * @param nodeExternals Externals for the Node.js compilation.
18+ * @param nodeExternals Coma separated list of Externals for the Node.js compilation.
19+ * @param compileEdge Force compiling for the edge runtime when true
1920 * @return The configuration and the build directory.
2021 */
2122export async function compileOpenNextConfig (
2223 baseDir : string ,
2324 openNextConfigPath ?: string ,
24- nodeExternals ?: string ,
25+ { nodeExternals = "" , compileEdge = false } = { } ,
2526) {
2627 const sourcePath = path . join (
2728 baseDir ,
@@ -32,7 +33,7 @@ export async function compileOpenNextConfig(
3233 let configPath = compileOpenNextConfigNode (
3334 sourcePath ,
3435 buildDir ,
35- nodeExternals ? nodeExternals . split ( "," ) : [ ] ,
36+ nodeExternals . split ( "," ) ,
3637 ) ;
3738
3839 // On Windows, we need to use file:// protocol to load the config file using import()
@@ -52,13 +53,13 @@ export async function compileOpenNextConfig(
5253 const usesEdgeRuntime =
5354 ( config . middleware ?. external && config . middleware . runtime !== "node" ) ||
5455 Object . values ( config . functions || { } ) . some ( ( fn ) => fn . runtime === "edge" ) ;
55- if ( ! usesEdgeRuntime ) {
56+ if ( usesEdgeRuntime || compileEdge ) {
57+ compileOpenNextConfigEdge ( sourcePath , buildDir , config . edgeExternals ?? [ ] ) ;
58+ } else {
59+ // Skip compiling for the edge runtime.
5660 logger . debug (
5761 "No edge runtime found in the open-next.config.ts. Using default config." ,
5862 ) ;
59- //Nothing to do here
60- } else {
61- compileOpenNextConfigEdge ( sourcePath , buildDir , config . edgeExternals ?? [ ] ) ;
6263 }
6364
6465 return { config, buildDir } ;
0 commit comments