@@ -15,6 +15,7 @@ import { getNextjsVersion } from './util';
1515import { constructWebpackConfigFunction } from './webpack' ;
1616
1717let showedExportModeTunnelWarning = false ;
18+ let showedExperimentalBuildModeWarning = false ;
1819
1920/**
2021 * Modifies the passed in Next.js configuration with automatic build-time instrumentation and source map upload.
@@ -67,6 +68,27 @@ function getFinalConfigObject(
6768 }
6869 }
6970
71+ if ( process . argv . includes ( '--experimental-build-mode' ) ) {
72+ if ( ! showedExperimentalBuildModeWarning ) {
73+ showedExperimentalBuildModeWarning = true ;
74+ // eslint-disable-next-line no-console
75+ console . warn (
76+ '[@sentry/nextjs] The Sentry Next.js SDK does not currently fully support next build --experimental-build-mode' ,
77+ ) ;
78+ }
79+ if ( process . argv . includes ( 'generate' ) ) {
80+ // Next.js v15.3.0-canary.1 splits the experimental build into two phases:
81+ // 1. compile: Code compilation
82+ // 2. generate: Environment variable inlining and prerendering (We don't instrument this phase, we inline in the compile phase)
83+ //
84+ // We assume a single “full” build and reruns Webpack instrumentation in both phases.
85+ // During the generate step it collides with Next.js’s new inliner (they do some bad replacements in the inliner)
86+ // producing malformed JS and build failures.
87+ // We skip Sentry processing during generate to avoid this issue.
88+ return incomingUserNextConfigObject ;
89+ }
90+ }
91+
7092 setUpBuildTimeVariables ( incomingUserNextConfigObject , userSentryOptions , releaseName ) ;
7193
7294 const nextJsVersion = getNextjsVersion ( ) ;
0 commit comments