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

error no matching export current_component - svelte 5 and sveltekit ^2.0 #10275

Closed
3 tasks done
JonathonRP opened this issue Jan 19, 2024 · 33 comments · Fixed by #11807
Closed
3 tasks done

error no matching export current_component - svelte 5 and sveltekit ^2.0 #10275

JonathonRP opened this issue Jan 19, 2024 · 33 comments · Fixed by #11807
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug

Comments

@JonathonRP
Copy link
Contributor

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

latest

Framework Version

svelte 5, sveltekit 2

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

svelte version ^5 and sveltekit ^2
install by guide, run dev.

Expected Result

no error message

Actual Result

error message - `No matching export in 'svelte' for import 'current_component'

@github-actions github-actions bot added the Package: sveltekit Issues related to the Sentry SvelteKit SDK label Jan 19, 2024
@Lms24
Copy link
Member

Lms24 commented Jan 23, 2024

Hi @JonathonRP I believe this issue is related to our component tracking feature not working well with SvelteKit 2 / Svelte 5. It's something we need to look into but I believe the root cause is ultimately the same as in #10276

Can you confirm that your setup is identical in both issues? Or did you change something to get around one of the two errors you reported?

@JonathonRP
Copy link
Contributor Author

@Lms24 setup for this is without disabling tracking withSentryConfig. As component tracking is on by default which I was attempting to work around by disabling but found that had errors no matter the route I took. I tried both svelte browser version and sveltekit version.

@JonathonRP
Copy link
Contributor Author

@socketopp
Copy link

I came across this when starting a new project using '@sentry/svelte', '@sentry_integration' while using ^7.95.0, with @sveltejs/kit version ^2.4.3 along with vite "^5.0.3".

X [ERROR] No matching export in "node_modules/svelte/src/internal/index.js" for import "current
_component"
    node_modules/@sentry/svelte/esm/performance.js:3:9:
      3 │ import { current_component } from 'svelte/internal';

And in the browser I would get 504 Outdated Optimize Dep) on @sentry_integration and @sentry/svelte.

Workaround would be to exclude these in vite.config.ts

optimizeDeps: {
    exclude: ['@sentry/svelte', '@sentry_integration']
},

@Lms24
Copy link
Member

Lms24 commented Jan 24, 2024

Hi @socketopp are you also using Svelte 5? I was under the impression that current_component was/will only be dropped with Svelte 5.

I'm wondering where you're getting @sentry_integration from - it's not a package of ours. Do you mean @sentry/integrations?

@socketopp
Copy link

Hi @socketopp are you also using Svelte 5?

Yes I am using "svelte": "^5.0.0-next.1",

@sentry/integrations

Sorry typo from my end.
I meant @sentry/integrations.
However, there is nothing wrong with that lib. Seems that the error comes from @sentry/svelte.

When I don't exclude it in the optimizeDeps, I receive these errors in Network tab and the page continuously load.

/node_modules/.vite/deps/@sentry_svelte.js
Status 504 Outdated Optimize Dep
/node_modules/.vite/deps/@sentry_integrations.js
Status 504 Outdated Optimize Dep

@Lms24
Copy link
Member

Lms24 commented Jan 24, 2024

I investigated this a bit today but there's an important piece of information missing: Svelte 5 is not yet supported by our SDK. This is on purpose because we can't guarantee support for a framework version that's not stable yet. However, if you don't use @sentry/svelte but @sentry/sveltekit, chances are you might be missing this information because installing won't necessarily show the peerDependency conflict: @sentry/svelte only allows Svelte 3 and 4 as peer dependencies.

Ideally, we find a way to unblock Svelte 5 users without changing too much but I tried doing so in #10311 and #10312 but turns out, changing the package.json properties will make our tests unusable because our jest version is too old 🥲

So this needs more work and I'm currently super busy with ~10 other tasks. I'll write this up in a proper issue for now but can't give you an ETA. Again, we do not support Svelte 5 until it becomes stable. So all the work I'm doing here would be merely preparation for this for you to use at your own risk.

@JonathonRP
Copy link
Contributor Author

@Lms24 one idea if this is caused by performance instrumentation, is there a way to disable performance instrumentation?

@Lms24
Copy link
Member

Lms24 commented Jan 24, 2024

This is not caused by performance instrumentation. It's caused by Vite pre-bundling the SDK and trying to resolve the current_component import at this point. This no longer exists in Svelte 5 --> error.

@socketopp mentioned a workaround but for me this locally produced some other errors. Might be worth giving this a try but no guarantees, sorry.

@JonathonRP
Copy link
Contributor Author

This is not caused by performance instrumentation. It's caused by Vite pre-bundling the SDK and trying to resolve the current_component import at this point. This no longer exists in Svelte 5 --> error.

@socketopp mentioned a workaround but for me this locally produced some other errors. Might be worth giving this a try but no guarantees, sorry.

Thanks, I'll try. Yeah internal isn't a stable API to relay on according to sveltekit team. To me it seems like a fall back that if you just didn't import components would have to be supplied manually which I think should be fine and expected behavior, but might be a minor breaking change

@JonathonRP
Copy link
Contributor Author

optimizeDeps: {
		exclude: ['@sentry/sveltekit']
	},

this gets rid of the error, but for me sveltekit app is still not interactive which is my blocker and reason I cared about error, my app
https://stackblitz.com/edit/sveltejs-kit-template-default-2lc4he?file=vite.config.js

@Lms24
Copy link
Member

Lms24 commented Jan 24, 2024

hmm you seem to be getting the same error like me if you open your browser console. Looks like excluding the SDK from the optimizations causes this error:

image

Which is weird because we only use magic-string on the server side. I wonder how it ends up in the client bundle.

@socketopp
Copy link

To confirm, did you revert back to SvelteKit 1.x? SvelteKit 2.x with Svelte 4 should work with Sentry. Only Svelte 5 is not supported.

I reverted back to SvelteKit 1.x since SvelteKit 2.x used Vite/Svelte 5. I totally agree with not supporting 5 since it's clearly not completely stable.

@Lms24
Copy link
Member

Lms24 commented Jan 25, 2024

Just to make sure: Our SvelteKit SDK should support SvelteKit 2 with Vite 5 and Svelte 4. As far as I can tell from this investigation, only the addition of Svelte 5 will cause issues.
If Vite 5 is also causing issues with our SDK, that's something we should look at separately.

If you reverted for other reason, no worries :) I just wanna make sure it's not us causing problems that aren't on our radar yet.

@JonathonRP
Copy link
Contributor Author

JonathonRP commented Jan 25, 2024

To confirm, did you revert back to SvelteKit 1.x? SvelteKit 2.x with Svelte 4 should work with Sentry. Only Svelte 5 is not supported.

I reverted back to SvelteKit 1.x since SvelteKit 2.x used Vite/Svelte 5. I totally agree with not supporting 5 since it's clearly not completely stable.

Sveltekit 2 only uses vite 5, I installed svelte 5.

And yes I don't mind the not supporting svelte 5

@JonathonRP
Copy link
Contributor Author

I still think svelte/internals shouldn't be used

I agree and we'll remove it. PR is already up but as I said it requires more stuff. If you just remove the import, you'll get another error in Svelte 5. As I said multiple times by now I can't tackle this at right now but it's on our list and tracked in #10318.

@Lms24 is the other issues after removing that line specifically the library testing with jest?
If so, I would love to help with that can willing to create a PR.

@Lms24
Copy link
Member

Lms24 commented Jan 25, 2024

All the items tracked in #10318 need to be done for Svelte 5 support as far as we can tell right now. Feel free to give upgrading to vitest a try if you want. Happy to review the PR. We're already using Vitest in our Astro and SvelteKit packages, so ideally, we use it similarly here.

I think though, considering removing the current_component import is a "soft-breaking" change we'll just merge everything in with v8. This will happen soon.

bradleyayers added a commit to bradleyayers/haohao.how that referenced this issue Jan 28, 2024
bradleyayers added a commit to bradleyayers/haohao.how that referenced this issue Jan 28, 2024
@bradleyayers
Copy link

@JonathonRP
Copy link
Contributor Author

@Lms24 has this been merged or released yet?

@lforst
Copy link
Member

lforst commented Mar 7, 2024

@JonathonRP The SDK does not yet support svelte 5. Progress is tracked here #10318.

@Lms24
Copy link
Member

Lms24 commented Apr 26, 2024

Hey everyone, 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)!

Thanks for your patience and special shout out to @JonathonRP for setting the ground stone by porting our Svelte SDK tests from Jest to Vitest (#10350)!

@JonathonRP
Copy link
Contributor Author

Hey everyone, 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)!

Thanks for your patience and special shout out to @JonathonRP for setting the ground stone by porting our Svelte SDK tests from Jest to Vitest (#10350)!

Is this still releasing today?

@JonathonRP
Copy link
Contributor Author

JonathonRP commented Apr 30, 2024

@Lms24 I have upgraded to beta, but do I also need svelte package at new beta? I'm trying today with only sveltekit on beta and getting build errors for performance.js access current_component...

Actually for some reason pnpm installed latest and not next tag version

@JonathonRP
Copy link
Contributor Author

JonathonRP commented May 1, 2024

@Lms24 I'm using spotlight and getting error that a is not a function... that's seems to come from using spotlight and sentry, it's inside Browserclient.addIntegration, setupIntegration, gw.setupOnce

I could also make another issue for this, if you like?

@lforst
Copy link
Member

lforst commented May 2, 2024

@JonathonRP Yes please open another issue with reproduction steps. Thank you!

@Lms24
Copy link
Member

Lms24 commented May 2, 2024

@JonathonRP sorry for the late response; I'm currently out sick and just saw this. Before you open another issue, please try upgrading to the Spotlight 2.x alpha. Since you're using v8 of the Svelte(kit) SDK, Spotlight needs to be update to its new major as well. More information here: https://github.com/getsentry/spotlight/releases/tag/%40spotlightjs%2Fspotlight%402.0.0-alpha.1

@JonathonRP
Copy link
Contributor Author

@JonathonRP sorry for the late response; I'm currently out sick and just saw this. Before you open another issue, please try upgrading to the Spotlight 2.x alpha. Since you're using v8 of the Svelte(kit) SDK, Spotlight needs to be update to its new major as well. More information here: https://github.com/getsentry/spotlight/releases/tag/%40spotlightjs%2Fspotlight%402.0.0-alpha.1

I'll give that a try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants