Skip to content

fix(sveltekit): Read SvelteKit config from the Vite plugin - #23678

Draft
chargome wants to merge 1 commit into
developfrom
fix/sveltekit-3-kit-config
Draft

fix(sveltekit): Read SvelteKit config from the Vite plugin#23678
chargome wants to merge 1 commit into
developfrom
fix/sveltekit-3-kit-config

Conversation

@chargome

Copy link
Copy Markdown
Member

SvelteKit 3 removed svelte.config.js (adapter, files and outDir now go to the sveltekit()
Vite plugin), and SvelteKit 2.66+ lets users move their config there too. The SDK still imported
svelte.config.js, so those setups silently fell back to defaults — breaking source map upload
paths and rewriteFrames for custom adapter out, outDir or hooks paths.

The config now comes from the SvelteKit Vite plugin's api.options, normalized across both
majors. svelte.config.js stays as the fallback — SvelteKit only exposes api.options from 2.62
on, so older 2.x apps still resolve through the file.

Not @sveltejs/load-config: it re-resolves the vite.config.js we're being constructed by, so it
waits on itself and hangs (verified on Vite 8) — and it reads this same api.options anyway.

SvelteKit 3 removed `svelte.config.js` (adapter, `files` and `outDir` now go to the `sveltekit()`
Vite plugin), and SvelteKit 2.66+ lets users move their config there too. The SDK still imported
`svelte.config.js`, so those setups silently fell back to defaults - breaking source map upload
paths and `rewriteFrames` for custom adapter `out`, `outDir` or hooks paths.

Read the config from the SvelteKit Vite plugin's `api.options` instead, normalized across both
majors. `svelte.config.js` stays as the fallback - SvelteKit only exposes `api.options` from 2.62
on, so older 2.x apps still resolve through the file.

Not `@sveltejs/load-config`: it re-resolves the `vite.config.js` we're being constructed by, so it
waits on itself and hangs - and it reads this same `api.options` anyway.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chargome chargome self-assigned this Aug 27, 2026
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 903e39c. Configure here.

config: async (config: UserConfig) => {
// Kick this off here (not in `closeBundle`) so the adapter is invoked before the build
// writes its output - see the note on the adapter output dir in `sentrySvelteKit()`.
const adapterOutputDir = await getAdapterOutputDir();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build deadlocks awaiting kit config

High Severity

The files-to-delete plugin awaits getAdapterOutputDir() (and thus getKitConfig()) inside its config hook, but the kit config promise is only guaranteed to settle in configResolved. Vite finishes every config hook before configResolved, and config.plugins in config is still the raw user array (often unresolved sveltekit() promises that findKitConfigInPlugins skips). The await never completes, so vite build hangs whenever source map upload plugins are registered (the default for production).

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 903e39c. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.56 kB - -
@sentry/browser (incl. Tracing, Replay) 88.11 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.51 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.82 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.51 kB - -
@sentry/browser (incl. Feedback) 45.79 kB - -
@sentry/browser (incl. sendFeedback) 33.35 kB - -
@sentry/browser (incl. FeedbackAsync) 38.46 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.31 kB - -
@sentry/react (incl. Tracing) 50.84 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.88 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.12 kB - -
CDN Bundle (incl. Logs, Metrics) 32.56 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.01 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73 kB - -
CDN Bundle (incl. Tracing, Replay) 86.62 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.52 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.33 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.42 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.01 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.68 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.08 kB - -
@sentry/core/server 65.3 kB - -
@sentry/core/browser 52.37 kB - -
@sentry/node 122.5 kB +0.02% +23 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.22 kB - -
@sentry/node - without tracing 87.66 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 102.19 kB +0.03% +21 B 🔺
@sentry/aws-serverless 95.82 kB +0.03% +25 B 🔺
@sentry/cloudflare (withSentry) - minified 199.61 kB - -
@sentry/cloudflare (withSentry) 495.94 kB - -

View base workflow run

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.

1 participant