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

Can you import @sentry/svelte like this? #6802

Closed
AbhiPrasad opened this issue Jan 16, 2023 Discussed in #6791 · 4 comments
Closed

Can you import @sentry/svelte like this? #6802

AbhiPrasad opened this issue Jan 16, 2023 Discussed in #6791 · 4 comments

Comments

@AbhiPrasad
Copy link
Member

Discussed in #6791

Originally posted by alexbjorlig January 16, 2023
Trying to migrate @sentry/browser to @sentry/svelte in my approach to support Sveltekit.

However if I import like this:

import { configureScope } from '@sentry/svelte';

I get an error?

SyntaxError: Named export 'configureScope' not found. The requested module '@sentry/svelte' is a CommonJS module, which may not support all module.exports as named exports

Is @sentry/svelte really a CommonJS module ?

@AbhiPrasad
Copy link
Member Author

AbhiPrasad commented Jan 16, 2023

@alexbjorlig tried digging into this more, but couldn't get anywhere. Could you provide any kind of reproduction to help us here? Or give some details about your bundling setup?

One possible issue could be that you're trying to import client-side code on the server. Where are you calling configureScope? If it's on the server-side, you'll have to use @sentry/node (or similar) instead of @sentry/svelte.

@alexbjorlig
Copy link

I tried to reproduce - but no luck 😞 Let's just close for now...

@Lms24
Copy link
Member

Lms24 commented Jan 17, 2023

Just for future reference: @sentry/svelte is meant for the client-side only. If you're using SvelteKit, please check that you're only using this package on the client-side. For the server-side, @sentry/node works quite well with some manual instrumentation: #5838 (comment)

Also, we're planning on improving SvelteKit support soon (#6692).

As suggested, I'm gonna go ahead and close this issue. Let us know if you encounter it again :)

@Lms24 Lms24 closed this as completed Jan 17, 2023
@jerriclynsjohn
Copy link

@Lms24 Also to be noted that @sentry/node will not work on Cloudflare Worker, so instead use toucan-js. Just for anyone who is using @sveltejs/adapter-cloudflare instead of node.

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

No branches or pull requests

4 participants