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

Rework SvelteKit SDK build time API #7787

Closed
Tracked by #7669
Lms24 opened this issue Apr 7, 2023 · 0 comments · Fixed by #7792
Closed
Tracked by #7669

Rework SvelteKit SDK build time API #7787

Lms24 opened this issue Apr 7, 2023 · 0 comments · Fixed by #7792
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Improvement

Comments

@Lms24
Copy link
Member

Lms24 commented Apr 7, 2023

Problem Statement

Currently, in SvelteKit, we instruct users to wrap withSentryViteConfig around their vite config object, similarly to withSentryConfig in the NextJS SDK. There are a couple of concerns with this approach:

  1. Depending on other wrappers people might use, our current types for the wrapper would cause TS errors. This is fixable by using broad enough generics but should we (see other points)?
  2. We received feedback that such a generic wrapper around the entire config is a little opaque in what it actually does and why we don’t simply use a plugin instead. Fair enough then!

Solution Brainstorm

Vite's plugin system exposes the configure hook which we can use to modify users' vite configs within a plugin.

So we'll build a "meta" SentrySvelteKitPlugin which adjusts the user's vite config:

  • Inject the init injection plugin if necessary
    • adjust the allowed serve directories
    • This will be dropped as a feature in favour of using hooks.
  • Inject the source maps plugin (=Sentry Vite Plugin w/ a couple of modifications)
  • In the future, possibly inject other plugins for auto instrumentation

We believe this provides a more transparent API than wrapping the entire config. At the same time, we don't lose the freedom to introduce further modification of the config.
The SvelteKit build plugin itself also uses the configure hook to merge user config w/ Kit-internal config.

Tasks

Preview Give feedback
No tasks being tracked yet.

ref: #6692 #7669

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: Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant