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

Aberta
#25,598 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
25/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
next.js, node.js, typescript, webpack

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
8.8k
Forks
1.9k
Merge médio
1d 8h
PRs com merge (30d)
744

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de getsentry/sentry-javascript

Todas as issues de getsentry/sentry-javascript

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.