Skip to content

fix: Properly configure SDK to be distributed as ESM #2171

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 2 commits into
base: main
Choose a base branch
from

Conversation

frederikprijck
Copy link
Member

@frederikprijck frederikprijck commented Jun 16, 2025

After merging #2028 and then reverting it again in #2046 , we are introducing the exact same changes again to fix our ESM bundling.

After merging #2028, it was called out to break a certain situation, so we immediately reverted again.
However, after some more investigation, we noticed that:

  • The broken behavior is only in local development mode when using turbopack
  • The broken behavior is only occuring when not following our guidance to require passing the request object to getSession() when used in middleware.

image

As this only breaks in local development, when using turbopack, and only when not passing down request to getSession in middleware (which is clearly called out in our docs not to do), we have decided to release this as a fix for #1945 and not consider this a breaking change.

Closes #1945

@frederikprijck frederikprijck requested a review from a team as a code owner June 16, 2025 14:37
@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.66%. Comparing base (2d59921) to head (0940bce).

Files with missing lines Patch % Lines
src/client/helpers/get-access-token.ts 0.00% 0 Missing and 1 partial ⚠️
src/client/index.ts 0.00% 0 Missing and 1 partial ⚠️
src/server/index.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2171   +/-   ##
=======================================
  Coverage   82.66%   82.66%           
=======================================
  Files          21       21           
  Lines        2060     2060           
  Branches      362      362           
=======================================
  Hits         1703     1703           
  Misses        350      350           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomer-dev
Copy link

Thank you!

@miriarte33
Copy link

Thanks @frederikprijck ! So, to clarify, after this fix is in, we will have to pass the request in to the getSession call in the middleware?

@frederikprijck
Copy link
Member Author

frederikprijck commented Jun 16, 2025

@miriarte33 Even before this fix, you should. Not passing it in is not supported (we call it out here), but it will work in some cases.

If you are not passing request to getSession, it will not work after this PR locally when using --turbopack, but build + start still works fine.

But again, not passing request in the middleware is not a scenario we support, even tho it may or may not work in certain scenario's.

For clarity, I have reached out to the folks at vercel to talk about this, because I think this is an issue with turbopack.

@miriarte33
Copy link

Makes perfect sense, thanks

@frederikprijck frederikprijck enabled auto-merge (squash) June 16, 2025 15:05
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.

Testing helper generateSessionCookie error: subpath './testing' is not defined by "exports"
4 participants