11// @ts -check
22
3- const { readFileSync } = require ( 'node: fs' ) ;
4- const path = require ( 'node: path' ) ;
3+ const { readFileSync } = require ( 'fs' ) ;
4+ const path = require ( 'path' ) ;
55const { createSecureHeaders } = require ( 'next-secure-headers' ) ;
66const pc = require ( 'picocolors' ) ;
77
8- const workspaceRoot = path . resolve ( __dirname , '..' , '..' ) ;
8+ const workspaceRoot = path . resolve ( __dirname , '..' , '..' , '..' ) ;
99/**
1010 * Once supported replace by node / eslint / ts and out of experimental, replace by
1111 * `import packageJson from './package.json' assert { type: 'json' };`
@@ -122,7 +122,18 @@ const nextConfig = {
122122 : '' ,
123123 reactStrictMode : true ,
124124 productionBrowserSourceMaps : NEXT_BUILD_ENV_SOURCEMAPS === true ,
125- optimizeFonts : true ,
125+ // optimizeFonts is enabled by default in Next.js 16
126+
127+ // Transpile packages that use React to ensure single React instance
128+ transpilePackages : [
129+ 'streamdown' ,
130+ 'd3-interpolate' ,
131+ 'd3-color' ,
132+ // Fix Turbopack "unexpected export *" warnings for CommonJS modules
133+ '@dnd-kit/core' ,
134+ '@dnd-kit/sortable' ,
135+ '@dnd-kit/utilities' ,
136+ ] ,
126137
127138 httpAgentOptions : {
128139 // @link https://nextjs.org/blog/next-11-1#builds--data-fetching
@@ -136,20 +147,14 @@ const nextConfig = {
136147
137148 // @link https://nextjs.org/docs/advanced-features/compiler#minification
138149 // @link discussion: https://github.com/vercel/next.js/discussions/30237
139- // Sometimes buggy so enable/disable when debugging.
140- swcMinify : true ,
150+ // swcMinify is enabled by default in Next.js 15+
141151
142152 compiler : {
143153 // emotion: true,
144154 } ,
145155
146- sentry : {
147- hideSourceMaps : true ,
148- // To disable the automatic instrumentation of API route handlers and server-side data fetching functions
149- // In other words, disable if you prefer to explicitly handle sentry per api routes (ie: wrapApiHandlerWithSentry)
150- // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-server-side-auto-instrumentation
151- autoInstrumentServerFunctions : false ,
152- } ,
156+ // Note: sentry configuration moved to withSentryConfig wrapper
157+ // See: https://docs.sentry.io/platforms/javascript/guides/nextjs/
153158
154159 // @link https://nextjs.org/docs/basic-features/image-optimization
155160 images : {
@@ -187,6 +192,10 @@ const nextConfig = {
187192 ? { output : 'standalone' , outputFileTracing : true }
188193 : { } ) ,
189194
195+ // Server-only packages that should not be bundled for the browser
196+ // @link https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages
197+ serverExternalPackages : [ 'next-i18next' , 'i18next-fs-backend' ] ,
198+
190199 experimental : {
191200 // @link https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
192201 ...( NEXT_BUILD_ENV_OUTPUT === 'standalone' ? { outputFileTracingRoot : workspaceRoot } : { } ) ,
@@ -204,15 +213,29 @@ const nextConfig = {
204213 // appDir: true,
205214 } ,
206215
216+ // Turbopack configuration (Next.js 16 default bundler)
217+ turbopack : {
218+ // Set workspace root to fix multiple lockfile detection
219+ root : workspaceRoot ,
220+ rules : {
221+ '*.svg' : {
222+ loaders : [ '@svgr/webpack' ] ,
223+ as : '*.js' ,
224+ } ,
225+ } ,
226+ resolveAlias : {
227+ // Required: next-i18next and i18next-fs-backend require 'fs' at top level
228+ fs : './turbopack-empty-stub.js' ,
229+ } ,
230+ } ,
231+
207232 typescript : {
208233 ignoreBuildErrors : ! NEXT_BUILD_ENV_TYPECHECK ,
209234 tsconfigPath : NEXT_BUILD_ENV_TSCONFIG ,
210235 } ,
211236
212- eslint : {
213- ignoreDuringBuilds : ! NEXT_BUILD_ENV_LINT ,
214- // dirs: [`${__dirname}/src`],
215- } ,
237+ // Note: eslint configuration is no longer supported in next.config.js
238+ // Use ESLint CLI directly: npx eslint .
216239
217240 // @link https://nextjs.org/docs/api-reference/next.config.js/rewrites
218241 async rewrites ( ) {
@@ -266,6 +289,21 @@ const nextConfig = {
266289 config . resolve . fallback = { ...config . resolve . fallback , fs : false } ;
267290 }
268291
292+ // Handle node: protocol imports for server-side (e.g., node:fs from i18next-fs-backend)
293+ // This tells webpack to treat node: protocol imports as external commonjs modules
294+ if ( isServer ) {
295+ config . externals = config . externals || [ ] ;
296+ config . externals . push (
297+ ( /** @type {{ request: string } } */ { request } , /** @type {Function } */ callback ) => {
298+ if ( request . startsWith ( 'node:' ) ) {
299+ // Convert node:fs -> fs, node:path -> path, etc.
300+ return callback ( null , 'commonjs ' + request . slice ( 5 ) ) ;
301+ }
302+ callback ( ) ;
303+ }
304+ ) ;
305+ }
306+
269307 // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/tree-shaking/
270308 config . plugins . push (
271309 new webpack . DefinePlugin ( {
@@ -304,6 +342,8 @@ const nextConfig = {
304342 APP_NAME : packageJson . name ?? 'not-in-package.json' ,
305343 APP_VERSION : packageJson . version ?? 'not-in-package.json' ,
306344 BUILD_TIME : new Date ( ) . toISOString ( ) ,
345+ // Note: Sentry debug/tracing variables are handled via webpack DefinePlugin
346+ // and cannot be set via Next.js env config (reserved key format)
307347 } ,
308348} ;
309349
@@ -313,26 +353,22 @@ if (NEXT_BUILD_ENV_SENTRY_ENABLED === true) {
313353 try {
314354 // https://docs.sentry.io/platforms/javascript/guides/nextjs/
315355 const { withSentryConfig } = require ( '@sentry/nextjs' ) ;
316- // @ts -ignore because sentry does not match nextjs current definitions
317356 config = withSentryConfig ( config , {
318- // Additional config options for the Sentry Webpack plugin. Keep in mind that
319- // the following options are set automatically, and overriding them is not
320- // recommended:
321- // release, url, org, project, authToken, configFile, stripPrefix ,
322- // urlPrefix, include, ignore
323- // For all available options, see:
324- // https://github.com/getsentry/sentry-webpack-plugin#options.
325- // silent: isProd, // Suppresses all logs
326- dryRun : NEXT_BUILD_ENV_SENTRY_UPLOAD_DRY_RUN === true ,
327- silent : NEXT_BUILD_ENV_SENTRY_DEBUG === false ,
357+ // Sentry 10.x options
358+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/build/
359+ bundleSizeOptimizations : {
360+ excludeDebugStatements : ! NEXT_BUILD_ENV_SENTRY_DEBUG ,
361+ excludeTracing : ! NEXT_BUILD_ENV_SENTRY_TRACING ,
362+ } ,
363+ sourcemaps : {
364+ disable : NEXT_BUILD_ENV_SENTRY_UPLOAD_DRY_RUN ,
365+ } ,
366+ silent : ! NEXT_BUILD_ENV_SENTRY_DEBUG ,
328367 } ) ;
329368 console . log ( `- ${ pc . green ( 'info' ) } Sentry enabled for this build` ) ;
330369 } catch {
331370 console . log ( `- ${ pc . red ( 'error' ) } Could not enable sentry, import failed` ) ;
332371 }
333- } else {
334- const { sentry, ...rest } = config ;
335- config = rest ;
336372}
337373
338374if ( tmModules . length > 0 ) {
0 commit comments