Commit 3b7c41d
ref(nextjs)!: Move
The `node` export condition matches for any Node process and is declared before
`import`, so a bare string pointing at the CJS build won every Node resolution
and made the `import` entry below it unreachable. ESM consumers got the CJS
build, where `cjs-module-lexer` cannot see the `export *` re-exports from
`@sentry/core` and `@sentry/node`, leaving `captureException` and friends
`undefined` on a namespace import.
`node` could not simply be split, because the server entry also re-exported
build-time config code that resolves webpack loader and template paths with
`__dirname` — a `ReferenceError` in an ES module. Moving `withSentryConfig` and
`SentryBuildOptions` to their own entry point takes that code out of the runtime
graph and lets `node` split like every other condition already does.
`./config` deliberately resolves to CommonJS under both conditions, since
`next.config.mjs` is loaded by a plain Node ESM loader. This is safe because the
module holds no SDK state. It also matches the other framework SDKs, which keep
their build plugins on `./vite`, `./module` and `./middleware`.
Drop the no-op `withSentryConfig` passthroughs from the client and edge builds:
they only existed so the name stayed resolvable when Next compiled a module that
imported it for those runtimes, which cannot happen now.
Add the `.js` extension to the `next/constants` import. It sits in the runtime
graph, and Node does no extension resolution for ESM, so it fails at link time
once the ESM server build is the one actually loaded.
BREAKING CHANGE: `withSentryConfig` and `SentryBuildOptions` are no longer
exported from `@sentry/nextjs`. Import them from `@sentry/nextjs/config`.
Fixes #22791
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>withSentryConfig to @sentry/nextjs/config
1 parent 1718e70 commit 3b7c41d
31 files changed
Lines changed: 192 additions & 51 deletions
File tree
- dev-packages/e2e-tests/test-applications
- nextjs-14
- nextjs-15-basepath
- nextjs-15-intl
- nextjs-15-t3
- nextjs-15
- nextjs-16-bun
- nextjs-16-cacheComponents
- nextjs-16-cf-workers
- nextjs-16-streaming-cacheComponents
- nextjs-16-streaming
- nextjs-16-trailing-slash
- tests
- nextjs-16-tunnel
- nextjs-16-userfeedback
- nextjs-16
- nextjs-app-dir
- nextjs-orpc
- nextjs-otlp
- nextjs-pages-dir
- nextjs-sourcemaps
- supabase-nextjs
- docs/migration
- packages/nextjs
- src
- client
- common/utils
- edge
- test
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments