Skip to content

feat(nextjs): Bump Webpack Plugin to version 2 and rework config options #10978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,43 @@ The following previously deprecated API has been removed from the `@sentry/nextj
- `IS_BUILD`
- `isBuild`

#### Merging of the Sentry Webpack Plugin options and SDK Build options

With version 8 of the Sentry Next.js SDK, `withSentryConfig` will no longer accept 3 arguments. The second argument
(holding options for the Sentry Webpack plugin) and the third argument (holding options for SDK build-time
configuration) should now be passed as one:

```ts
// OLD
const nextConfig = {
// Your Next.js options...
};

module.exports = withSentryConfig(
nextConfig,
{
// Your Sentry Webpack Plugin Options...
},
{
// Your Sentry SDK options...
},
);

// NEW
const nextConfig = {
// Your Next.js options...
};

module.exports = withSentryConfig(nextConfig, {
// Your Sentry Webpack Plugin Options...
// AND your Sentry SDK options...
});
```

#### Removal of the `sentry` property in your Next.js options (next.config.js)

With version 8 of the Sentry Next.js SDK, the SDK will no longer support passing Next.js options with a `sentry`
property to `withSentryConfig`. Please use the third argument of `withSentryConfig` to configure the SDK instead:
property to `withSentryConfig`. Please use the second argument of `withSentryConfig` to configure the SDK instead:

```ts
// v7
Expand All @@ -572,21 +605,25 @@ const nextConfig = {
// Your Next.js options...
};

module.exports = withSentryConfig(
nextConfig,
{
// Your Sentry Webpack Plugin Options...
},
{
// Your Sentry SDK options...
},
);
module.exports = withSentryConfig(nextConfig, {
// Your Sentry Webpack Plugin Options...
// AND your Sentry SDK options...
});
```

The reason for this change is to have one consistent way of defining the SDK options. We hope that this change will
reduce confusion when setting up the SDK, with the upside that the explicit option is properly typed and will therefore
have code completion.

#### Updated the `@sentry/webpack-plugin` dependency to version 2

We bumped the internal usage of `@sentry/webpack-plugin` to a new major version. This comes with multiple upsides like a
simpler configuration interface and the use of new state of the art Debug ID technology. Debug IDs will simplify the
setup for source maps in Sentry and will not require you to match stack frame paths to uploaded artifacts anymore.

To see the new options, check out the docs at https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/,
or look at the TypeScript type definitions of `withSentryConfig`.

### Astro SDK

#### Removal of `trackHeaders` option for Astro middleware
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@sentry/types": "8.0.0-alpha.2",
"@sentry/utils": "8.0.0-alpha.2",
"@sentry/vercel-edge": "8.0.0-alpha.2",
"@sentry/webpack-plugin": "1.21.0",
"@sentry/webpack-plugin": "2.14.3",
"chalk": "3.0.0",
"resolve": "1.22.8",
"rollup": "2.78.0",
Expand Down
1 change: 0 additions & 1 deletion packages/nextjs/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export type { SentryWebpackPluginOptions } from './types';
export { withSentryConfig } from './withSentryConfig';
Loading