Skip to content

feat(sveltekit): Update @sentry/vite-plugin to 2.x and adjust options API #10813

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

Merged
merged 7 commits into from
Feb 28, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Feb 26, 2024

This PR updates @sentry/vite-plugin used in the SvelteKit SDK from version 0.6.x to the latest 2.x version. In line with this change, we now also decoupled the public API of the vite plugin from the SvelteKit SDK public API, meaning we can bump to a higher plugin major version while we stay in the same SDK major version.

Concrete changes:

  • We now use DebugId-based sourcemap upload 🎉
  • Due to architecture changes in @sentry/vite-plugin, our sentrySvelteKit plugin factory function returns 6 (5x sourcemap, 1x auto instrumentation) plugins instead of previously two. This is because the Vite plugin now consists of several individual plugins.
  • We still have to modify source maps a bit before uploading them and all of this should still happen as late as possible. So we still create a customized version of the uploading plugin and return that instead of the original one.
  • Also added direct usage of MagicString to inject global values needed during runtime. Previously, I just handed my modified code to the original plugin's transform hook which might have even messed up source maps.
  • The new API is a subset of all Sentry Vite plugin options.
    • I'm happy to add more options before merging this PR. I just don't think we need all of them right from the start. As an alternative, we could allow users to pass in arbitrary options and we type them as unknown or something along these lines 🤔

Example usage (showing all available options; all are optional)

sentrySvelteKit({
  autoUploadSourceMaps: true,
  sourceMapsUploadOptions: {
    org: process.env.SENTRY_ORG,
    project: process.env.SENTRY_PROJECT,
    authToken: process.env.SENTRY_AUTH_TOKEN,
    release: {
	    name: '1.0.1',
	    inject: true
    },
    sourcemaps: {
	    assets: ['./build/*/**/*'],
	    ignore: ['**/build/client/**/*'],
	    filesToDeleteAfterUpload: ['./build/**/*.map']
    }
  },
  autoInstrument: true,
  debug: true
}),

closes #9835
closes #8283

@Lms24 Lms24 force-pushed the lms/feat-sveltekit-bump-vite-plugin branch from fe057c2 to 396b555 Compare February 26, 2024 16:49
@Lms24 Lms24 marked this pull request as ready for review February 27, 2024 13:40
@Lms24 Lms24 requested review from lforst and AbhiPrasad February 27, 2024 13:40
Copy link
Contributor

github-actions bot commented Feb 27, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.22 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 68.48 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.4 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.02 KB (0%)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 32.66 KB (0%)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 32.66 KB (0%)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.86 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 30.86 KB (0%)
@sentry/browser - Webpack (gzipped) 22.12 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.63 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.33 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.14 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.67 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 210.84 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 99.56 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.76 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.22 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 68.75 KB (0%)
@sentry/react - Webpack (gzipped) 22.15 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 85.16 KB (0%)
@sentry/nextjs Client - Webpack (gzipped) 49.52 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 17.14 KB (0%)

@Lms24 Lms24 force-pushed the lms/feat-sveltekit-bump-vite-plugin branch from 5ae792a to 40f2435 Compare February 27, 2024 15:51
@mydea mydea force-pushed the lms/feat-sveltekit-bump-vite-plugin branch from 40f2435 to f823bde Compare February 28, 2024 08:39
@mydea mydea merged commit ba80f79 into develop Feb 28, 2024
@mydea mydea deleted the lms/feat-sveltekit-bump-vite-plugin branch February 28, 2024 11:26
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 this pull request may close these issues.

[v8] Bump @sentry/vite-plugin in @sentry/sveltekit & stop exposing options directly Outdated @sentry/vite-plugin used in SvelteKit package
3 participants