Skip to content

Commit c9211d8

Browse files
chargomeclaude
andauthored
ref(nextjs)!: Move withSentryConfig to @sentry/nextjs/config (#23628)
Moves `withSentryConfig` and `SentryBuildOptions` to a new `@sentry/nextjs/config` entry point, separating build-time code from the SDK runtime. This matches the other framework SDKs, which expose their build plugins on `./vite`, `./module` and `./middleware` rather than the main entry. `./config` resolves to CommonJS under both conditions, since `next.config.mjs` is loaded by a plain Node ESM loader and the build-time code resolves webpack loader and template paths with `__dirname`, which is not defined in an ES module. Safe because the module holds no SDK state. ```js // next.config.mjs - import { withSentryConfig } from '@sentry/nextjs'; + import { withSentryConfig } from '@sentry/nextjs/config'; ``` Breaks every existing `next.config`, but at the first build. Runtime APIs untouched. Docs and the wizard need the same change. This is a prerequisite for splitting the `node` export condition (#22791), left for a follow-up. Serving the ESM server build to Next breaks two things CommonJS currently hides: 87 browser-only names are missing from the server build, and `cacheComponents` prerendering rejects the `crypto.randomUUID()` inside `captureException`. Refs #22791 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8217a85 commit c9211d8

31 files changed

Lines changed: 169 additions & 50 deletions

File tree

MIGRATION.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,21 @@ The legacy per-transaction profiling sampling options were removed. Configure se
12791279

12801280
### `@sentry/nextjs`
12811281

1282+
`withSentryConfig` and the `SentryBuildOptions` type moved to the `@sentry/nextjs/config` entry point and are no
1283+
longer exported from `@sentry/nextjs`:
1284+
1285+
```js
1286+
// next.config.mjs
1287+
1288+
// before
1289+
import { withSentryConfig } from '@sentry/nextjs';
1290+
1291+
// after
1292+
import { withSentryConfig } from '@sentry/nextjs/config';
1293+
```
1294+
1295+
The no-op `withSentryConfig` passthroughs that the client and edge builds exported were removed along with it.
1296+
12821297
The following long-deprecated top-level options in `withSentryConfig` / the `sentry` config were removed. Most of them
12831298
moved under the `webpack` option in v10; use the replacement listed below instead:
12841299

dev-packages/e2e-tests/test-applications/nextjs-14/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { withSentryConfig } = require('@sentry/nextjs');
1+
const { withSentryConfig } = require('@sentry/nextjs/config');
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {};

dev-packages/e2e-tests/test-applications/nextjs-15-basepath/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { withSentryConfig } = require('@sentry/nextjs');
1+
const { withSentryConfig } = require('@sentry/nextjs/config');
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {

dev-packages/e2e-tests/test-applications/nextjs-15-intl/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { withSentryConfig } = require('@sentry/nextjs');
1+
const { withSentryConfig } = require('@sentry/nextjs/config');
22
const createNextIntlPlugin = require('next-intl/plugin');
33

44
const withNextIntl = createNextIntlPlugin('./i18n/request.ts');

dev-packages/e2e-tests/test-applications/nextjs-15-t3/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ await import('./src/env.js');
33
/** @type {import("next").NextConfig} */
44
const config = {};
55

6-
import { withSentryConfig } from '@sentry/nextjs';
6+
import { withSentryConfig } from '@sentry/nextjs/config';
77

88
export default withSentryConfig(config, {
99
webpack: {

dev-packages/e2e-tests/test-applications/nextjs-15/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { withSentryConfig } = require('@sentry/nextjs');
1+
const { withSentryConfig } = require('@sentry/nextjs/config');
22

33
// Simulate Vercel environment for cron monitoring tests
44
process.env.VERCEL = '1';

dev-packages/e2e-tests/test-applications/nextjs-16-bun/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withSentryConfig } from '@sentry/nextjs';
1+
import { withSentryConfig } from '@sentry/nextjs/config';
22
import type { NextConfig } from 'next';
33

44
const nextConfig: NextConfig = {};

dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withSentryConfig } from '@sentry/nextjs';
1+
import { withSentryConfig } from '@sentry/nextjs/config';
22
import type { NextConfig } from 'next';
33

44
const nextConfig: NextConfig = {

dev-packages/e2e-tests/test-applications/nextjs-16-cf-workers/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withSentryConfig } from '@sentry/nextjs';
1+
import { withSentryConfig } from '@sentry/nextjs/config';
22
import type { NextConfig } from 'next';
33

44
const nextConfig: NextConfig = {};

dev-packages/e2e-tests/test-applications/nextjs-16-streaming-cacheComponents/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withSentryConfig } from '@sentry/nextjs';
1+
import { withSentryConfig } from '@sentry/nextjs/config';
22
import type { NextConfig } from 'next';
33

44
const nextConfig: NextConfig = {

0 commit comments

Comments
 (0)