-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(sveltekit): Add conditional exports #9872
Conversation
packages/sveltekit/package.json
Outdated
"exports": { | ||
"browser": "./build/esm/index.client.js", | ||
"node": "./build/cjs/index.server.js" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should have esm and cjs for both browser and node... (by adding objects with import
and require
fields)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should.
Ideally exports fields look something like so:

(from https://abhiprasad.github.io/talks/2023/publishing-javascript-libraries-made-easy.pdf)
I don't think we can get the types separated, so we can ignore that field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually esm is broken because of our http integration, so maybe we just dont expose that for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of the http integration but iirc there's also a require call in our http transport which we can't just get rid of 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shameless plug @AbhiPrasad :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbhiPrasad what's the advantage of the package.json
export?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbhiPrasad so we want this (considering server-side ESM is broken), correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the version from the screenshot and it still seems to work so going with it.
7b7a664
to
9d920da
Compare
9d920da
to
81563d0
Compare
adds a Sveltekit 2.0 E2E test application. Currently, we only test building. This shows that with #9872, our SDK works in SvelteKit 2.0. We should however add actual tests to both Kit 1.x and 2.x test apps.
Looks like Vite 5 module resolution for
@sentry/sveltekit
only works with defining conditional exports. Tested this locally with a Sverdle kit@1, kit@2 and the syntax website.It'd be nice to get confirmation that this fixes syntaxfm/website#1458 but based on my tests it should be fine 🤞
Added an e2e test for Kit 2.0 in #9873
ref #9851