Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dev-packages/rollup-utils/npmHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export function makeBaseNPMConfig(options = {}) {
// Allow wrappers or helper functions generated by rollup to use any ES2015 features
generatedCode: {
preset: 'es2015',
// With arrow functions, Node can't see `export *` exports when ESM code imports our CJS files.
arrowFunctions: false,
},

// don't add `"use strict"` to the top of cjs files
Expand Down
14 changes: 14 additions & 0 deletions packages/nextjs/test/serverExports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@ describe('Node-only integrations are statically detectable exports from every ru
},
);
});

/**
* Node loads this CJS file for ESM imports too, and must see that it re-exports everything from `@sentry/node`.
*
* Regression test for https://github.com/getsentry/sentry-javascript/issues/22791
*/
describe('CJS server build re-exports are detectable by Node', () => {
it('detects the `@sentry/node` re-export', async () => {
await init();
const { reexports } = parse(readFileSync(resolve(__dirname, '../build/cjs/index.server.js'), 'utf8'));

expect(reexports).toContain('@sentry/node');
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 3768aa9. Configure here.

});
Loading