@@ -18,7 +18,12 @@ export function getBuildPluginOptions({
1818 sentryBuildOptions : SentryBuildOptions ;
1919 releaseName : string | undefined ;
2020 distDirAbsPath : string ;
21- buildTool : 'webpack-client' | 'webpack-nodejs' | 'webpack-edge' | 'after-production-compile' ;
21+ buildTool :
22+ | 'webpack-client'
23+ | 'webpack-nodejs'
24+ | 'webpack-edge'
25+ | 'after-production-compile-webpack'
26+ | 'after-production-compile-turbopack' ;
2227 useRunAfterProductionCompileHook ?: boolean ; // Whether the user has opted into using the experimental hook
2328} ) : SentryBuildPluginOptions {
2429 const sourcemapUploadAssets : string [ ] = [ ] ;
@@ -34,15 +39,26 @@ export function getBuildPluginOptions({
3439 'webpack-nodejs' : '[@sentry/nextjs - Node.js]' ,
3540 'webpack-edge' : '[@sentry/nextjs - Edge]' ,
3641 'webpack-client' : '[@sentry/nextjs - Client]' ,
37- 'after-production-compile' : '[@sentry/nextjs - After Production Compile]' ,
42+ 'after-production-compile-webpack' : '[@sentry/nextjs - After Production Compile (Webpack)]' ,
43+ 'after-production-compile-turbopack' : '[@sentry/nextjs - After Production Compile (Turbopack)]' ,
3844 } [ buildTool ] ;
3945
40- if ( buildTool === 'after-production-compile' ) {
41- // Turbopack builds
46+ if ( buildTool . startsWith ( 'after-production-compile' ) ) {
4247 sourcemapUploadAssets . push (
43- path . posix . join ( normalizedDistDirAbsPath , '**' ) , // Next.js build output
48+ path . posix . join ( normalizedDistDirAbsPath , 'server' , '**' ) , // Standard output location for server builds
49+ path . posix . join ( normalizedDistDirAbsPath , 'serverless' , '**' ) , // Legacy output location for serverless Next.js
4450 ) ;
4551
52+ if ( buildTool === 'after-production-compile-turbopack' ) {
53+ sourcemapUploadAssets . push ( path . posix . join ( normalizedDistDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
54+ } else {
55+ // Webpack client builds
56+ sourcemapUploadAssets . push (
57+ path . posix . join ( normalizedDistDirAbsPath , 'static' , 'chunks' , 'pages' , '**' ) ,
58+ path . posix . join ( normalizedDistDirAbsPath , 'static' , 'chunks' , 'app' , '**' ) ,
59+ ) ;
60+ }
61+
4662 if ( sentryBuildOptions . sourcemaps ?. deleteSourcemapsAfterUpload ) {
4763 filesToDeleteAfterUpload . push (
4864 path . posix . join ( normalizedDistDirAbsPath , '**' , '*.js.map' ) ,
@@ -52,12 +68,13 @@ export function getBuildPluginOptions({
5268 }
5369 } else {
5470 if ( buildTool === 'webpack-nodejs' || buildTool === 'webpack-edge' ) {
71+ // Webpack server builds
5572 sourcemapUploadAssets . push (
5673 path . posix . join ( distDirAbsPath , 'server' , '**' ) , // Standard output location for server builds
5774 path . posix . join ( distDirAbsPath , 'serverless' , '**' ) , // Legacy output location for serverless Next.js
5875 ) ;
5976 } else {
60- // Client builds
77+ // Webpack client builds
6178 if ( sentryBuildOptions . widenClientFileUpload ) {
6279 sourcemapUploadAssets . push ( path . posix . join ( distDirAbsPath , 'static' , 'chunks' , '**' ) ) ;
6380 } else {
@@ -67,19 +84,6 @@ export function getBuildPluginOptions({
6784 ) ;
6885 }
6986
70- // We want to include main-* files if widenClientFileUpload is true as they have proven to be useful
71- if ( ! sentryBuildOptions . widenClientFileUpload ) {
72- sourcemapUploadIgnore . push ( path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'main-*' ) ) ;
73- }
74-
75- // Always ignore framework, polyfills, and webpack files
76- sourcemapUploadIgnore . push (
77- path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework-*' ) ,
78- path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework.*' ) ,
79- path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'polyfills-*' ) ,
80- path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'webpack-*' ) ,
81- ) ;
82-
8387 // File deletion for webpack client builds
8488 // If the user has opted into using the experimental hook, we delete the source maps in the hook instead
8589 if ( sentryBuildOptions . sourcemaps ?. deleteSourcemapsAfterUpload && ! useRunAfterProductionCompileHook ) {
@@ -95,6 +99,19 @@ export function getBuildPluginOptions({
9599 }
96100 }
97101
102+ // We want to include main-* files if widenClientFileUpload is true as they have proven to be useful
103+ if ( ! sentryBuildOptions . widenClientFileUpload ) {
104+ sourcemapUploadIgnore . push ( path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'main-*' ) ) ;
105+ }
106+
107+ // Always ignore framework, polyfills, and webpack files
108+ sourcemapUploadIgnore . push (
109+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework-*' ) ,
110+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'framework.*' ) ,
111+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'polyfills-*' ) ,
112+ path . posix . join ( distDirAbsPath , 'static' , 'chunks' , 'webpack-*' ) ,
113+ ) ;
114+
98115 // If the user has opted into using the experimental hook, we skip sourcemap uploads in the plugin
99116 const shouldSkipSourcemapsUpload = useRunAfterProductionCompileHook && buildTool . startsWith ( 'webpack' ) ;
100117
@@ -106,13 +123,12 @@ export function getBuildPluginOptions({
106123 telemetry : sentryBuildOptions . telemetry ,
107124 debug : sentryBuildOptions . debug ,
108125 errorHandler : sentryBuildOptions . errorHandler ,
109- reactComponentAnnotation :
110- buildTool === 'after-production-compile'
111- ? undefined
112- : {
113- ...sentryBuildOptions . reactComponentAnnotation ,
114- ...sentryBuildOptions . unstable_sentryWebpackPluginOptions ?. reactComponentAnnotation ,
115- } ,
126+ reactComponentAnnotation : buildTool . startsWith ( 'after-production-compile' )
127+ ? undefined
128+ : {
129+ ...sentryBuildOptions . reactComponentAnnotation ,
130+ ...sentryBuildOptions . unstable_sentryWebpackPluginOptions ?. reactComponentAnnotation ,
131+ } ,
116132 silent : sentryBuildOptions . silent ,
117133 url : sentryBuildOptions . sentryUrl ,
118134 sourcemaps : {
0 commit comments