Skip to content

Commit 8b75a33

Browse files
docs(nextjs): Move webpack build config under webpack namespace (#15691)
We are moving the only-webpack related configurations under `webpack` namespace to better fit our goal of communicating the SDK readiness for Turbopack by default. This involved moving several options to be nested under a `webpack` path in the build configuration. This is meant to be released once this getsentry/sentry-javascript#18343 goes live, so I will keep this open until then. Will keep it in draft as well. The SDK PR adds warnings for those deprecated options and warns users about using them if detected so I don't think we need to do that here once it goes live. --------- Co-authored-by: Sarah Mischinger <sarah@codingwriter.com>
1 parent 185594c commit 8b75a33

File tree

1 file changed

+59
-60
lines changed
  • docs/platforms/javascript/guides/nextjs/configuration/build

1 file changed

+59
-60
lines changed

docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -182,50 +182,6 @@ Note: Enabling this option can lead to longer build times.
182182

183183
</SdkOption>
184184

185-
<SdkOption name="autoInstrumentServerFunctions" type="boolean" defaultValue="true">
186-
187-
Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.
188-
189-
</SdkOption>
190-
191-
<SdkOption name="autoInstrumentMiddleware" type="boolean" defaultValue="true">
192-
193-
Automatically instrument Next.js middleware with error and performance monitoring.
194-
195-
</SdkOption>
196-
197-
<SdkOption name="autoInstrumentAppDirectory" type="boolean" defaultValue="true">
198-
199-
Automatically instrument components in the `app` directory with error monitoring.
200-
201-
</SdkOption>
202-
203-
<SdkOption name="excludeServerRoutes" type="Array<RegExp | string>">
204-
Exclude specific server-side API routes or pages from automatic Sentry instrumentation during build time.
205-
This option takes an array of strings or regular expressions and affects pages in the `pages` and `app` directories.
206-
207-
When defining routes, note the following:
208-
209-
- Specify pages as routes and not as file system paths. For example, write `/animals` instead of `pages/animals/index.js`.
210-
- Make sure that any provided string matches the route exactly, has a leading slash, and doesn't have a trailing slash.
211-
212-
```javascript
213-
excludeServerRoutes: [
214-
"/some/excluded/route",
215-
"/excluded/route/with/[parameter]",
216-
/^\/route\/beginning\/with\/some\/prefix/,
217-
/\/routeContainingASpecificPathSegment\/?/,
218-
];
219-
```
220-
221-
<Alert level="info">
222-
If you're building your Next.js application with Turbopack, this option will
223-
have no effect. The Sentry SDK will no longer apply build-time instrumentation
224-
and will rely purely on Next.js telemetry features.
225-
</Alert>
226-
227-
</SdkOption>
228-
229185
<SdkOption name="tunnelRoute" type="string | boolean">
230186
<Alert level="info">
231187
This feature requires **Next.js version 11+** and doesn't currently work with self-hosted Sentry instances.
@@ -251,9 +207,18 @@ Learn more about tunneling in the <PlatformLink to="/troubleshooting/#dealing-wi
251207

252208
</SdkOption>
253209

254-
<SdkOption name="automaticVercelMonitors" type="boolean" defaultValue="false">
210+
<SdkOption name="useRunAfterProductionCompileHook" type="boolean" defaultValue="false(webpack)|true(turbopack)">
255211

256-
Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.
212+
<Alert level="info" title="Version support">
213+
You can use this option with Next.js version 15.4.1 and later.
214+
</Alert>
215+
216+
Enables the use of the [`runAfterProductionCompile` hook from Next.js](https://nextjs.org/docs/architecture/nextjs-compiler#runafterproductioncompile) to upload sourcemaps after the build is completed.
217+
218+
- This option is set to `true` by default for Turbopack as there are no alternative ways to upload sourcemaps here.
219+
- This option is set to `false` for Webpack as the default behavior is to upload sourcemaps during the build process using the [Sentry Webpack Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins).
220+
221+
**Important:** Enabling this option will mutate your Next.js build output by injecting [Debug IDs](/platforms/javascript/guides/nextjs/sourcemaps/troubleshooting_js/debug-ids/) via the Sentry CLI. If you are relying on any sort of integrity hashes for your build artifacts, you will need to disable this option.
257222

258223
</SdkOption>
259224

@@ -272,37 +237,59 @@ The route manifest is a build-time generated mapping of your Next.js App Router
272237

273238
</SdkOption>
274239

275-
<SdkOption name="reactComponentAnnotation.enabled" type="boolean" defaultValue="false">
240+
## Next.js Webpack Options
276241

277-
Enables React component name tracking. When enabled, it annotates React components with data attributes that allow Sentry to track which components users interacted with in features like Session Replay and breadcrumbs.
242+
<Alert level="info">
243+
These options only take effect if you're using Webpack. If you're using
244+
Turbopack, these options will have no effect.
245+
</Alert>
246+
247+
<SdkOption name="webpack.autoInstrumentServerFunctions" type="boolean" defaultValue="true">
248+
249+
Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.
278250

279251
</SdkOption>
280252

281-
<SdkOption name="reactComponentAnnotation.ignoredComponents" type="string[] | undefined">
253+
<SdkOption name="webpack.autoInstrumentMiddleware" type="boolean" defaultValue="true">
282254

283-
A list of React component names to exclude from component annotation.
255+
Automatically instrument Next.js middleware with error and performance monitoring.
284256

285257
</SdkOption>
286258

287-
<SdkOption name="useRunAfterProductionCompileHook" type="boolean" defaultValue="false(webpack)|true(turbopack)">
259+
<SdkOption name="webpack.autoInstrumentAppDirectory" type="boolean" defaultValue="true">
288260

289-
<Alert level="info" title="Version support">
290-
You can use this option with Next.js version 15.4.1 and later.
291-
</Alert>
261+
Automatically instrument components in the `app` directory with error monitoring.
292262

293-
Enables the use of the [`runAfterProductionCompile` hook from Next.js](https://nextjs.org/docs/architecture/nextjs-compiler#runafterproductioncompile) to upload sourcemaps after the build is completed.
263+
</SdkOption>
294264

295-
- This option is set to `true` by default for Turbopack as there are no alternative ways to upload sourcemaps here.
296-
- This option is set to `false` for Webpack as the default behavior is to upload sourcemaps during the build process using the [Sentry Webpack Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins).
265+
<SdkOption name="webpack.excludeServerRoutes" type="Array<RegExp | string>">
266+
Exclude specific server-side API routes or pages from automatic Sentry instrumentation during build time.
267+
This option takes an array of strings or regular expressions and affects pages in the `pages` and `app` directories.
297268

298-
**Important:** Enabling this option will mutate your Next.js build output by injecting [Debug IDs](/platforms/javascript/guides/nextjs/sourcemaps/troubleshooting_js/debug-ids/) via the Sentry CLI. If you are relying on any sort of integrity hashes for your build artifacts, you will need to disable this option.
269+
When defining routes, note the following:
270+
271+
- Specify pages as routes and not as file system paths. For example, write `/animals` instead of `pages/animals/index.js`.
272+
- Make sure that any provided string matches the route exactly, has a leading slash, and doesn't have a trailing slash.
273+
274+
```javascript
275+
webpack.excludeServerRoutes: [
276+
"/some/excluded/route",
277+
"/excluded/route/with/[parameter]",
278+
/^\/route\/beginning\/with\/some\/prefix/,
279+
/\/routeContainingASpecificPathSegment\/?/,
280+
];
281+
```
299282

283+
</SdkOption>
300284

285+
<SdkOption name="webpack.automaticVercelMonitors" type="boolean" defaultValue="false">
301286

302-
</SdkOption>
287+
Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.
288+
289+
</SdkOption>
303290

304291
<SdkOption
305-
name="unstable_sentryWebpackPluginOptions"
292+
name="webpack.unstable_sentryWebpackPluginOptions"
306293
type="SentryWebpackPluginOptions"
307294
>
308295
Pass configuration options directly to the [Sentry Webpack
@@ -315,3 +302,15 @@ Enables the use of the [`runAfterProductionCompile` hook from Next.js](https://n
315302
in any release.
316303
</Alert>
317304
</SdkOption>
305+
306+
<SdkOption name="webpack.reactComponentAnnotation.enabled" type="boolean" defaultValue="false">
307+
308+
Enables React component name tracking. When enabled, it annotates React components with data attributes that allow Sentry to track which components users interacted with in features like Session Replay and breadcrumbs.
309+
310+
</SdkOption>
311+
312+
<SdkOption name="webpack.reactComponentAnnotation.ignoredComponents" type="string[] | undefined">
313+
314+
A list of React component names to exclude from component annotation.
315+
316+
</SdkOption>

0 commit comments

Comments
 (0)