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

Offen
#25,598 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
next.js, node.js, typescript, webpack

Rechercherichtung

Start by reading the package export conditions for @sentry/nextjs and the related changes in #25599 and #22791; the issue does not name source files or tests. The work is complete when Node ESM imports and bundlers select the ESM server build while default imports keep working, with the listed Next.js versions, bundlers, cacheComponents, custom server, and auto-instrumentation scenarios covered. The issue describes major-version behavior changes and several cross-cutting compatibility checks.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Bug Next.js Node.js
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 https://github.com/getsentry/sentry-javascript/pull/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, https://github.com/getsentry/sentry-javascript/pull/25599

Vorherrschende Sprache
TypeScript
Sterne
8.8k
Forks
1.9k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
744

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/sentry-javascript

Alle Issues in getsentry/sentry-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.