@@ -7,6 +7,7 @@ import * as fs from 'fs';
77import * as path from 'path' ;
88import { createRouteManifest } from './manifest/createRouteManifest' ;
99import type { RouteManifest } from './manifest/types' ;
10+ import { constructTurbopackConfig } from './turbopack' ;
1011import type {
1112 ExportedNextConfig as NextConfig ,
1213 NextConfigFunction ,
@@ -251,6 +252,8 @@ function getFinalConfigObject(
251252 }
252253
253254 let nextMajor : number | undefined ;
255+ const isTurbopack = process . env . TURBOPACK ;
256+ let isTurbopackSupported = false ;
254257 if ( nextJsVersion ) {
255258 const { major, minor, patch, prerelease } = parseSemver ( nextJsVersion ) ;
256259 nextMajor = major ;
@@ -262,6 +265,7 @@ function getFinalConfigObject(
262265 ( major === 15 && minor > 3 ) ||
263266 ( major === 15 && minor === 3 && patch === 0 && prerelease === undefined ) ||
264267 ( major === 15 && minor === 3 && patch > 0 ) ) ;
268+ isTurbopackSupported = isSupportedVersion ;
265269 const isSupportedCanary =
266270 major !== undefined &&
267271 minor !== undefined &&
@@ -274,7 +278,7 @@ function getFinalConfigObject(
274278 parseInt ( prerelease . split ( '.' ) [ 1 ] || '' , 10 ) >= 28 ;
275279 const supportsClientInstrumentation = isSupportedCanary || isSupportedVersion ;
276280
277- if ( ! supportsClientInstrumentation && process . env . TURBOPACK ) {
281+ if ( ! supportsClientInstrumentation && isTurbopack ) {
278282 if ( process . env . NODE_ENV === 'development' ) {
279283 // eslint-disable-next-line no-console
280284 console . warn (
@@ -307,12 +311,17 @@ function getFinalConfigObject(
307311 ] ,
308312 } ,
309313 } ) ,
310- webpack : constructWebpackConfigFunction (
311- incomingUserNextConfigObject ,
312- userSentryOptions ,
313- releaseName ,
314- routeManifest ,
315- ) ,
314+ webpack : ! isTurbopack
315+ ? constructWebpackConfigFunction ( incomingUserNextConfigObject , userSentryOptions , releaseName , routeManifest )
316+ : undefined ,
317+ ...( isTurbopackSupported && isTurbopack
318+ ? {
319+ turbopack : constructTurbopackConfig ( {
320+ userNextConfig : incomingUserNextConfigObject ,
321+ routeManifest,
322+ } ) ,
323+ }
324+ : { } ) ,
316325 } ;
317326}
318327
0 commit comments