fix(sveltekit): Read SvelteKit config from the Vite plugin - #23678
fix(sveltekit): Read SvelteKit config from the Vite plugin#23678chargome wants to merge 1 commit into
Conversation
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>
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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(); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 903e39c. Configure here.
size-limit report 📦
|


SvelteKit 3 removed
svelte.config.js(adapter,filesandoutDirnow go to thesveltekit()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 uploadpaths and
rewriteFramesfor custom adapterout,outDiror hooks paths.The config now comes from the SvelteKit Vite plugin's
api.options, normalized across bothmajors.
svelte.config.jsstays as the fallback — SvelteKit only exposesapi.optionsfrom 2.62on, so older 2.x apps still resolve through the file.
Not
@sveltejs/load-config: it re-resolves thevite.config.jswe're being constructed by, so itwaits on itself and hangs (verified on Vite 8) — and it reads this same
api.optionsanyway.