Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sveltekit): Add conditional exports #9872

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Dec 15, 2023

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

@Lms24 Lms24 mentioned this pull request Dec 15, 2023
@Lms24 Lms24 self-assigned this Dec 15, 2023
@Lms24 Lms24 marked this pull request as ready for review December 18, 2023 11:05
Comment on lines 16 to 25
"exports": {
"browser": "./build/esm/index.client.js",
"node": "./build/cjs/index.server.js"
},
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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:

image

(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.

Copy link
Member

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.

Copy link
Member Author

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 馃

Copy link
Member

Choose a reason for hiding this comment

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

Shameless plug @AbhiPrasad :P

Copy link
Member Author

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?

Copy link
Member Author

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?
image

Copy link
Member Author

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.

@Lms24 Lms24 force-pushed the lms/fix-sveltekit-2-exports branch from 7b7a664 to 9d920da Compare December 19, 2023 10:48
@Lms24 Lms24 enabled auto-merge (squash) December 19, 2023 10:49
@Lms24 Lms24 force-pushed the lms/fix-sveltekit-2-exports branch from 9d920da to 81563d0 Compare December 19, 2023 10:52
@Lms24 Lms24 merged commit 6d32228 into develop Dec 19, 2023
94 checks passed
@Lms24 Lms24 deleted the lms/fix-sveltekit-2-exports branch December 19, 2023 11:20
Lms24 added a commit that referenced this pull request Dec 19, 2023
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.
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.

None yet

3 participants