File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,9 @@ export async function build({
262
262
const nodeVersion = await getNodeVersion ( entryPath , undefined , config , meta ) ;
263
263
const spawnOpts = getSpawnOptions ( meta , nodeVersion ) ;
264
264
265
+ const isServerTarget =
266
+ nextVersionRange && isServerTargetNext ( nextVersionRange ) ;
267
+
265
268
// Add Vercel build environment variables that some dependencies need
266
269
// to determine a Vercel like build environment
267
270
spawnOpts . env = {
@@ -273,6 +276,15 @@ export async function build({
273
276
INIT_CWD : entryPath ,
274
277
} ;
275
278
279
+ // Next.js changed the default output folder beginning with
280
+ // 10.0.8-canary.15 from `.next/serverless` to `.next/server`.
281
+ // This is an opt-out of this behavior for older versions.
282
+ // https://github.com/dealmore/terraform-aws-next-js/issues/86
283
+ // https://github.com/vercel/next.js/pull/22731
284
+ if ( ! isServerTarget ) {
285
+ spawnOpts . env [ 'NEXT_PRIVATE_TARGET' ] = 'experimental-serverless-trace' ;
286
+ }
287
+
276
288
const nowJsonPath = await findUp ( [ 'now.json' , 'vercel.json' ] , {
277
289
cwd : entryPath ,
278
290
} ) ;
@@ -351,8 +363,6 @@ export async function build({
351
363
console . warn ( 'WARNING: You should not upload the `.next` directory.' ) ;
352
364
}
353
365
354
- const isServerTarget =
355
- nextVersionRange && isServerTargetNext ( nextVersionRange ) ;
356
366
const isLegacy =
357
367
! isServerTarget && nextVersionRange && isLegacyNext ( nextVersionRange ) ;
358
368
debug (
You can’t perform that action at this time.
0 commit comments