Skip to content

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

Merged
frederikprijck merged 2 commits intomainfrom
fix/esm
Jun 18, 2025
Merged

fix: Properly configure SDK to be distributed as ESM#2171
frederikprijck merged 2 commits intomainfrom
fix/esm

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

@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 (622aec0) to head (9e46dfa).
Report is 1 commits behind head on main.

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
@frederikprijck frederikprijck merged commit d916c18 into main Jun 18, 2025
12 checks passed
@frederikprijck frederikprijck deleted the fix/esm branch June 18, 2025 12:29
@frederikprijck frederikprijck mentioned this pull request Jun 20, 2025
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"

6 participants