Repository navigation
Conversation
When plain Node ESM code imports `@sentry/nextjs`, Node loads the CJS build, because the `node` export condition points to it. Namespace imports then miss about 180 exports (`captureException`, `setUser`, …), which are silently `undefined`. Rollup writes `export *` in CJS as a loop with an arrow function, but Node only recognizes that loop with a `function` callback. So Node can't see the `@sentry/node` re-exports. Fixed by turning off arrow functions in Rollup's generated helpers. - Only that loop changes, and only in CJS output. ESM output and CDN bundles are unchanged, so size-limit is not affected. - Also fixes `@sentry/remix`, which pins `node` to CJS too. - On Node 20, 22 and 24, namespace imports now match `require()`. Bun and Deno were not affected. - Splitting the `node` condition is not needed for this fix and is still blocked (see #23628). - Supersedes #25378, which re-exports only 8 of the missing names. A unit test checks that Node sees the `@sentry/node` re-export. Fixes #22791
size-limit report 📦Compared: 541d164 (PR test merge using develop at a01cfca) Against: a01cfca (develop) · base run #62876 ✅ Baseline matches: this diff contains only this PR's changes.
|
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3768aa9. Configure here.
| const { reexports } = parse(readFileSync(resolve(__dirname, '../build/cjs/index.server.js'), 'utf8')); | ||
|
|
||
| expect(reexports).toContain('@sentry/node'); | ||
| }); |
There was a problem hiding this comment.
Test asserts the wrong re-export
Medium Severity
The new regression test expects cjs-module-lexer to report @sentry/node on index.server.js, but that entry only star-exports the local ./server module. The @sentry/node star-export lives in server/index.js. The assertion can fail even after the helper change, so this does not lock in the Node ESM interop fix.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 3768aa9. Configure here.


When plain Node ESM code imports
@sentry/nextjs, Node loads the CJS build, because thenodeexport condition points to it. Namespace imports then miss about 180 exports (captureException,setUser, …), which are silentlyundefined.Rollup writes
export *in CJS as a loop with an arrow function, but Node only recognizes that loop with afunctioncallback. So Node can't see the@sentry/nodere-exports. Fixed by turning off arrow functions in Rollup's generated helpers.Splitting the
nodecondition is not needed for this fix. It is planned for later: #25598require()and default imports work as before@sentry/remix, which pinsnodeto CJS tooA unit test checks that Node sees the
@sentry/nodere-export.Fixes #22791