Skip to content

ref(nextjs): Prefer esm/index.server.js over CJS version #16144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mischnic
Copy link

@mischnic mischnic commented Apr 28, 2025

This makes bundlers prefer the ESM version of index.server.js, for better tree shaking.

The ESM versions are already listed first for the edge versions

@Lms24 Lms24 changed the title Prefer esm/index.server.js over CJS version ref(nextjs): Prefer esm/index.server.js over CJS version Apr 28, 2025
@Lms24
Copy link
Member

Lms24 commented Apr 28, 2025

Hey @mischnic thanks for opening this PR!

To assess priority: Is the current exports declaration blocking you in some way? Could you elaborate a bit more what the specific issue is that this PR solves? Thanks!

I started our CI so that we check if our NextJS E2E tests are still passing. Unfortunately, exports changes are always a bit risky.

Also gonna ask @chargome to review

@Lms24 Lms24 requested a review from chargome April 28, 2025 12:52
@mischnic
Copy link
Author

Sorry for the short description, this is the fix for #16121 as with this change, importing @sentry/nextjs in a Node.js context resolves to an ESM file and Turbopack is able to treeshake away everything except the required export (before, this import lead to withSentryConfig to be included in the user's project).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants