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

SvelteKit wizard fails to add sentrySvelteKit plugin in vite configs that don't directly default-export the config #362

Closed
Lms24 opened this issue Jul 17, 2023 · 4 comments · Fixed by #380
Assignees

Comments

@Lms24
Copy link
Member

Lms24 commented Jul 17, 2023

Environment

What version are you running? Etc.

Steps to Reproduce

  1. Clone turborepo svelte example
  2. Run wizard

Expected Result

Wizard successfully adds sentrySvelteKit plugin to vite.config.js

Actual Result

Wizard fails at vite.config.js injection with error

■  Error while setting up the SvelteKit SDK:
│
●  TypeError: 'set' on proxy: trap returned falsish for property 'plugins'

Probably some problem with magicast. Need to investigate further

Update

This isn't directly related to turborepo but to the structure of the vite.config.js. Explanation: #362 (comment)

@Lms24
Copy link
Member Author

Lms24 commented Jul 17, 2023

Discovered in getsentry/sentry-javascript#8325

@Lms24 Lms24 changed the title SvelteKit wizard in Turborepo fails to add sentrySvelteKit plugin SvelteKit wizard fails to add sentrySvelteKit plugin in Turborepo project Jul 17, 2023
@happysalada
Copy link

happysalada commented Jul 20, 2023

Just got this exact same error.
For other people coming in, it looks like the step that is missing is the modification of the vite.config.js file. So this is just a problem with sourcemaps, the rest should work fine.

@Lms24
Copy link
Member Author

Lms24 commented Jul 20, 2023

it looks like the step that is missing is the modification of the vite.config.js file

Yes, that's correct. The setup for vite is very simple though. As a workaround I suggest following code snippet

I believe I identified the issue:

Currently, we can only handle adding the plugin if the config export is directly exported:

export default {
  // config object...
}

Apparently, magicast, the library we use for this modification, doesn't yet handle other typical config options like

const config = {...}
export default config;

We should add this; probably help Antfu out and contribute upstream.

Regardless, we'll also provide a fallback copy/paste snippet directly in the wizard if we encounter an error so that we can always help out directly in the wizard.

Will fix this soon.

@Lms24
Copy link
Member Author

Lms24 commented Jul 26, 2023

I opened unjs/magicast#69 to fix this upstream in magicast. I'll give the maintainers a few days to respond. In the meantime, I'll work on the fallback mechanism to provide copy/paste instructions if we fail to modify the vite config AST.

@Lms24 Lms24 changed the title SvelteKit wizard fails to add sentrySvelteKit plugin in Turborepo project SvelteKit wizard fails to add sentrySvelteKit plugin in vite configs that don't directly default-export the config Jul 26, 2023
@Lms24 Lms24 self-assigned this Jul 27, 2023
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 a pull request may close this issue.

2 participants