11import { mkdirSync } from "node:fs" ;
2- import url from "node:url" ;
32
43import { build } from "esbuild" ;
54import fs from "fs" ;
@@ -19,8 +18,6 @@ import { openNextReplacementPlugin } from "../../plugins/replacement.js";
1918import { openNextResolvePlugin } from "../../plugins/resolve.js" ;
2019import { BuildOptions , copyOpenNextConfig , esbuildAsync } from "../helper.js" ;
2120
22- const __dirname = url . fileURLToPath ( new URL ( "." , import . meta. url ) ) ;
23-
2421interface BuildEdgeBundleOptions {
2522 appBuildOutputPath : string ;
2623 middlewareInfo : MiddlewareInfo ;
@@ -99,8 +96,8 @@ export async function buildEdgeBundle({
9996 middlewareInfo,
10097 nextDir : path . join ( appBuildOutputPath , ".next" ) ,
10198 edgeFunctionHandlerPath : path . join (
102- __dirname ,
103- "../../ core" ,
99+ options . openNextDistDir ,
100+ "core" ,
104101 "edgeFunctionHandler.js" ,
105102 ) ,
106103 isInCloudfare,
@@ -222,7 +219,11 @@ export async function generateEdgeBundle(
222219 await buildEdgeBundle ( {
223220 appBuildOutputPath,
224221 middlewareInfo : fn ,
225- entrypoint : path . join ( __dirname , "../../adapters" , "edge-adapter.js" ) ,
222+ entrypoint : path . join (
223+ options . openNextDistDir ,
224+ "adapters" ,
225+ "edge-adapter.js" ,
226+ ) ,
226227 outfile : path . join ( outputPath , "index.mjs" ) ,
227228 options,
228229 overrides : fnOptions . override ,
0 commit comments