Skip to content

Split node export condition of @sentry/nextjs into import/require #25598

Open

Description

@s1gr1d

Description

exports["."].node points to the CJS build, so Node ESM imports and bundlers that build the Next.js server never get the ESM server build.

Blockers (from #23628):

  • 87 browser-only names are missing from the ESM server build.
  • cacheComponents prerendering rejects the crypto.randomUUID() call inside captureException.

Keep ESM default imports (import Sentry from '@sentry/nextjs') working with a default export in the ESM server build.

Not breaking by itself, but reasons to ship it in a major (planned v12):

  • Every Next.js server bundle switches to the ESM builds of @sentry/nextjs and @sentry/node.
  • @sentry/node behaves differently as ESM (default integrations, auto-instrumentation differences) - see feat(node): Make ESM output valid Node ESM #10928 (removes CJS-only integrations)
  • Mixed require/import can load two SDK copies in one process
  • Bundlers check named imports at build time, so names that are missing from the ESM build become build errors

When testing, cover webpack and Turbopack on all supported Next.js versions, cacheComponents, a custom server, and check that auto-instrumentation spans (e.g. http, DB) still show up.

@sentry/remix pins node to CJS the same way.

Refs #22791, #25599

Activity

  1. linear-code commented on Oct 21, 2026

    @linear-code
  2. added this to the 12.0.0 milestone on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions