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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Svelte 5 support #10318

Closed
4 tasks done
Tracked by #5194
Lms24 opened this issue Jan 24, 2024 · 12 comments · Fixed by #11807
Closed
4 tasks done
Tracked by #5194

Prepare for Svelte 5 support #10318

Lms24 opened this issue Jan 24, 2024 · 12 comments · Fixed by #11807
Assignees
Milestone

Comments

@Lms24
Copy link
Member

Lms24 commented Jan 24, 2024

Important

Svelte 5 is not yet stable. We can't bump peer dependencies before it goes stable because we can't guarantee support yet. This issue serves as a collection of things we need to do for Svelte 5 support at this time. We can do some preparations beforehand but we won't guarantee support.

Problem Statement

Our @sentry/svelte SDK is not fully compatible with Svelte 5. This has two reasons

  • Svelte 5 requires type: "module" and exports in package.json
  • Svelte 5 no longer exports the current_component internal API (this was risky to use in the first place but yeah here we are...)

Solution Brainstorm

Tried a quick update today but the blocker here is that we also need to upgrade Jest or switch to vitest.

Tasks

Preview Give feedback
  1. Lms24
  2. Lms24

closes #10275
closes #10276

@Lms24
Copy link
Member Author

Lms24 commented Jan 24, 2024

Added this to the v8 milestone. Might be worth to just expose the componentTrackingPreprocessor going forward and remove withSentryConfig again. I have the feeling this is not gonna play well with SvelteKit and I wanna stay away from such a general wrapper.

@dummdidumm
Copy link

dummdidumm commented Feb 28, 2024

👋 Svelte maintainer here - if you have any questions regarding how to adapt the SDK to Svelte 5, let me know. Ideally Svelte 5 provides the public APIs you need to achieve what you want.

@Lms24
Copy link
Member Author

Lms24 commented Mar 1, 2024

@dummdidumm thanks a lot! Are you planning on exposing a way of getting the component name in onMount callbacks? Previously we relied on the current_component internal API (I know, not smart) which was removed.

@dummdidumm
Copy link

What do you need the component name for?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Mar 1, 2024
@Lms24
Copy link
Member Author

Lms24 commented Mar 1, 2024

For a component mount and update time tracking utility we export from our Svelte SDK. We have some automatism around this (which we'll also rework in our next SDK major version) but this utility used to automatically obtain the component name without users having to specify it in Svelte 3 and 4.

If this is no longer possible in Svelte 5, that's fine, I was just wondering because I'll soon start reworking this feature for Svelte 5 support.

@dummdidumm
Copy link

Out of curiosity: how does this work for other frameworks? E.g. how do you obtain that name from React? Do they provide it? Or is there just no way and devs have to do something else there?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Mar 2, 2024
@lforst
Copy link
Member

lforst commented Mar 4, 2024

@dummdidumm Other frameworks often don't have this API at all and people have to add it manually. React has an API for this but it needs build-time config. We built a feature in our bundler plugins to annotate components: getsentry/sentry-javascript-bundler-plugins#468

@Lms24
Copy link
Member Author

Lms24 commented Apr 26, 2024

I just merged #11807 which auto-closed this issue. We'll make a new beta release for v8 of our SDK on Monday which will ship with support for Svelte 5 (compatible with the latest Svelte 5 preview)!

@happycollision
Copy link

I am testing out Svelte 5 and discovered this error message:

Uncaught (in promise) Error: Your application, or one of its dependencies, imported from 'svelte/internal', which was a private module used by Svelte 4 components that no longer exists in Svelte 5. It is not intended to be public API. If you're a library author and you used 'svelte/internal' deliberately, please raise an issue on https://github.com/sveltejs/svelte/issues detailing your use case.

The only package I see importing from svelte/internal is this one. Here is what I think is the relevant line of code:

alias: [{ find: /^svelte$/, replacement: 'svelte/internal' }],

@Lms24, would you like a separate issue opened for this, or do you want to do something else?

@Lms24
Copy link
Member Author

Lms24 commented May 13, 2024

@happycollision did you try out Svelte 5 with version 8.0.0 RC or beta of the @sentry/svelte SDK? The vite config you linked shouldn't even end up in the SDK package. It's just for local development/testing. Apart from that we don't import from svelte/internal at all so my guess is you're using version 7 (where we did still import from svelte/internal).

If you don't want to upgrade to a preview build, you're in luck: We're releasing 8.0.0 stable today :)

@happycollision
Copy link

Hah. I guess that’s the deal, then. All I did was check that I was on latest, not beta.

@Lms24
Copy link
Member Author

Lms24 commented May 13, 2024

Yup, we just released 8.0.0 - would love to hear if things work for you when you get a chance to upgrade :)

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

Successfully merging a pull request may close this issue.

5 participants