@@ -191,15 +191,12 @@ function initOutputDir(srcTempDir: string, options: BuildOptions) {
191191 ) ;
192192 }
193193 fs . rmSync ( options . outputDir , { recursive : true , force : true } ) ;
194- const destTempDir = options . tempDir ;
195- fs . mkdirSync ( destTempDir , { recursive : true } ) ;
196- fs . writeFileSync (
197- path . join ( destTempDir , "open-next.config.mjs" ) ,
198- openNextConfig ,
199- ) ;
194+ const { buildDir } = options ;
195+ fs . mkdirSync ( buildDir , { recursive : true } ) ;
196+ fs . writeFileSync ( path . join ( buildDir , "open-next.config.mjs" ) , openNextConfig ) ;
200197 if ( openNextConfigEdge ) {
201198 fs . writeFileSync (
202- path . join ( destTempDir , "open-next.config.edge.mjs" ) ,
199+ path . join ( buildDir , "open-next.config.edge.mjs" ) ,
203200 openNextConfigEdge ,
204201 ) ;
205202 }
@@ -215,7 +212,7 @@ async function createWarmerBundle(options: BuildOptions) {
215212 fs . mkdirSync ( outputPath , { recursive : true } ) ;
216213
217214 // Copy open-next.config.mjs into the bundle
218- copyOpenNextConfig ( options . tempDir , outputPath ) ;
215+ copyOpenNextConfig ( options . buildDir , outputPath ) ;
219216
220217 // Build Lambda code
221218 // note: bundle in OpenNext package b/c the adatper relys on the
@@ -258,7 +255,7 @@ async function createRevalidationBundle(options: BuildOptions) {
258255 fs . mkdirSync ( outputPath , { recursive : true } ) ;
259256
260257 //Copy open-next.config.mjs into the bundle
261- copyOpenNextConfig ( options . tempDir , outputPath ) ;
258+ copyOpenNextConfig ( options . buildDir , outputPath ) ;
262259
263260 // Build Lambda code
264261 await esbuildAsync (
@@ -297,7 +294,7 @@ async function createImageOptimizationBundle(options: BuildOptions) {
297294 fs . mkdirSync ( outputPath , { recursive : true } ) ;
298295
299296 // Copy open-next.config.mjs into the bundle
300- copyOpenNextConfig ( options . tempDir , outputPath ) ;
297+ copyOpenNextConfig ( options . buildDir , outputPath ) ;
301298
302299 const plugins = [
303300 openNextResolvePlugin ( {
@@ -636,7 +633,7 @@ async function createCacheAssets(options: BuildOptions) {
636633 ) ;
637634
638635 //Copy open-next.config.mjs into the bundle
639- copyOpenNextConfig ( options . tempDir , providerPath ) ;
636+ copyOpenNextConfig ( options . buildDir , providerPath ) ;
640637
641638 // TODO: check if metafiles doesn't contain duplicates
642639 fs . writeFileSync (
@@ -660,7 +657,7 @@ export function compileCache(
660657) {
661658 const { config } = options ;
662659 const ext = format === "cjs" ? "cjs" : "mjs" ;
663- const outfile = path . join ( options . outputDir , ".build" , `cache.${ ext } ` ) ;
660+ const outfile = path . join ( options . buildDir , `cache.${ ext } ` ) ;
664661
665662 const isAfter15 = compareSemver ( options . nextVersion , "15.0.0" ) >= 0 ;
666663
@@ -721,7 +718,7 @@ async function createMiddleware(options: BuildOptions) {
721718
722719 // Copy open-next.config.mjs
723720 copyOpenNextConfig (
724- options . tempDir ,
721+ options . buildDir ,
725722 outputPath ,
726723 config . middleware . override ?. wrapper === "cloudflare" ,
727724 ) ;
@@ -739,7 +736,7 @@ async function createMiddleware(options: BuildOptions) {
739736 } else {
740737 await buildEdgeBundle ( {
741738 entrypoint : path . join ( __dirname , "core" , "edgeFunctionHandler.js" ) ,
742- outfile : path . join ( outputDir , ".build" , "middleware.mjs" ) ,
739+ outfile : path . join ( options . buildDir , "middleware.mjs" ) ,
743740 ...commonMiddlewareOptions ,
744741 onlyBuildOnce : true ,
745742 } ) ;
0 commit comments