Skip to content

Commit db8ca2e

Browse files
move source maps options away from Next.js manual setup page (#12783)
* move manual setup source maps options from Next.js manual setup page * remove duplicate link from next.js source maps page
1 parent 5479f7c commit db8ca2e

File tree

3 files changed

+14
-58
lines changed

3 files changed

+14
-58
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ If set to `true`, the Sentry SDK will attempt to tree-shake code related to trac
150150

151151
Include Next.js-internal code and code from dependencies when uploading source maps.
152152

153+
<Expandable type="note" title="When and why to widen the upload scope.">
154+
If you find that there are some frames in your client-side stack traces that
155+
aren't getting source-mapped even when most others are, the issue might be
156+
that those frames are from files in `static/chunks/` rather than
157+
`static/chunks/pages/`. By default, such files aren't uploaded because the
158+
majority of the files in `static/chunks/` only contain Next.js or third-party
159+
code. To upload all of the files and source maps, including ones from
160+
third-party packages, set the `widenClientFileUpload` option to `true`.
161+
</Expandable>
162+
153163
Note: Enabling this option can lead to longer build times.
154164

155165
</SdkOption>

docs/platforms/javascript/guides/nextjs/manual-setup.mdx

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ export default withSentryConfig(nextConfig, {
6767
```
6868

6969
### Extend Sentry Webpack Plugin Options
70+
7071
`withSentryConfig` uses a [custom Webpack plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) to manage your sourcemaps and releases under the hood. If `withSentryConfig` does not provide the option you need to modify, you may override the `sentryWebpackPluginOptions` directly via `unstable_sentryWebpackPluginOptions`.
7172

7273
<Alert level="warning">
73-
Note that this option is unstable and its API may include breaking changes in any release.
74+
Note that this option is unstable and its API may include breaking changes in
75+
any release.
7476
</Alert>
7577

76-
7778
## Create Initialization Config Files
7879

7980
Create three files in the root directory of your Next.js application: `sentry.client.config.js`, `sentry.server.config.js` and `sentry.edge.config.js`. In these files, add your initialization code for the client-side SDK and server-side SDK, respectively. We've included some examples below.
@@ -175,7 +176,6 @@ export async function register() {
175176
}
176177
```
177178

178-
179179
Make sure that the `import` statements point to your newly created `sentry.server.config.(js|ts)` and `sentry.edge.config.(js|ts)` files.
180180

181181
## Report React Component Render Errors
@@ -457,60 +457,6 @@ Do not commit your auth token to version control.
457457
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
458458
```
459459

460-
### Disable Source Maps
461-
462-
You can disable the custom sourcemap plugin as follows:
463-
464-
```javascript {tabTitle:ESM} {filename:next.config.mjs}
465-
export default withSentryConfig(nextConfig, {
466-
sourcemaps: {
467-
disable: true,
468-
},
469-
});
470-
```
471-
472-
```javascript {tabTitle:CJS} {filename:next.config.js}
473-
module.exports = withSentryConfig(nextConfig, {
474-
sourcemaps: {
475-
disable: true,
476-
},
477-
});
478-
```
479-
480-
### Use `hidden-source-map`
481-
482-
Depending on your deployment setup, adding `sentry/nextjs` to your app may cause your source code to be visible in browser devtools when it wasn't before. (This happens because of the default behavior of [webpack's `source-map` built-in `devtool`](https://webpack.js.org/configuration/devtool/).) To prevent this, you can use `hidden-source-map` rather than `source-map`, which will prevent your built files from containing a `sourceMappingURL` comment, thus making sourcemaps invisible to the browser. To use `hidden-source-map`, add a `sentry` object to `nextConfig` above, and set the `hideSourceMaps` option to `true`:
483-
484-
```javascript {tabTitle:ESM} {filename:next.config.mjs}
485-
export default withSentryConfig(nextConfig, {
486-
hideSourceMaps: true,
487-
});
488-
```
489-
490-
```javascript {tabTitle:CJS} {filename:next.config.js}
491-
module.exports = withSentryConfig(nextConfig, {
492-
hideSourceMaps: true,
493-
});
494-
```
495-
496-
### Widen the Upload Scope
497-
498-
If you find that there are some frames in your client-side stack traces that aren't getting source-mapped even when most others are, the issue might be that those frames are from files in `static/chunks/` rather than `static/chunks/pages/`. By default, such files aren't uploaded because the majority of the files in `static/chunks/` only contain Next.js or third-party code.
499-
500-
To upload all of the files and source maps, including ones from third-party packages, set the `widenClientFileUpload` option to `true`:
501-
502-
```javascript {tabTitle:ESM} {filename:next.config.mjs}
503-
export default withSentryConfig(nextConfig, {
504-
widenClientFileUpload: true,
505-
});
506-
```
507-
508-
```javascript {tabTitle:CJS} {filename:next.config.js}
509-
module.exports = withSentryConfig(nextConfig, {
510-
widenClientFileUpload: true,
511-
});
512-
```
513-
514460
## Configure Tunneling to avoid Ad-Blockers
515461

516462
You might notice that Sentry events are sometimes blocked by ad blockers.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
`@sentry/nextjs` will generate and upload source maps automatically, in order to enable errors to have readable stack traces.
22

3-
To upload source maps, the `@sentry/nextjs` SDK uses the [Sentry webpack plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) under the hood. See the [Manual Configuration](../manual-setup/#configure-source-maps) page and the Sentry [webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin) for more details. If you are using Vercel, then you can also use the [Vercel integration](/organization/integrations/deployment/vercel/) to upload source maps during deployments automatically.
3+
To upload source maps, the `@sentry/nextjs` SDK uses the Sentry webpack plugin under the hood. See the [Build Options](../configuration/build/#source-maps-options) page and the Sentry [webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin) for more details. If you are using Vercel, then you can also use the [Vercel integration](/organization/integrations/deployment/vercel/) to upload source maps during deployments automatically.

0 commit comments

Comments
 (0)