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

未關閉
#25,598 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
next.js, node.js, typescript, webpack

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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

主要語言
TypeScript
星號
8.8k
分支
1.9k
平均合併
1 天 8 小時
30 天內合併 PR
744

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。