fix(sveltekit): Read SvelteKit config from the Vite plugin - #23678
Draft
chargome wants to merge 3 commits into
Draft
fix(sveltekit): Read SvelteKit config from the Vite plugin#23678chargome wants to merge 3 commits into
chargome wants to merge 3 commits 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>
Member
Author
|
bugbot run |
Contributor
size-limit report 📦
|
`sveltekit()` is an async factory in both SvelteKit majors, so the plugins array Vite passes to `config` hooks still holds an unresolved promise where the SvelteKit plugin will be - the config is only findable in `configResolved`. Awaiting it from the source maps plugin's `config` hook blocked the very phase that would resolve it, hanging `vite build` whenever source map upload was enabled (the default). Record the user's `build.sourcemap` setting in `config` (it has to be read before our own source map settings plugin overwrites it) and resolve the adapter output dir in `configResolved`, which is still early enough to run the adapter before the build writes anything. The e2e apps all disable source map upload, so nothing exercised this path; the Vite integration test now uses an async SvelteKit factory with uploads enabled, and hangs without this fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2fd3d9e. Configure here.
`process_config()` resolves `outDir` and `files.hooks.*` against the cwd before SvelteKit exposes them on the Vite plugin's `api.options`, so reading the config from there handed us absolute paths where `svelte.config.js` gave relative ones. That broke two things: the hooks file regexp gained a leading `//` and stopped matching any Vite module id, so the global values were no longer injected into `hooks.server.*` at all; and `__sentry_sveltekit_output_dir` became a build machine path that `rewriteFrames` can't match at runtime anywhere else. Normalizing in `normalizeKitConfig()` covers both sources and also drops the platform separator, which would have broken the same matching on Windows. Also settle the config promise in a `finally` so a throwing `configResolved` can't leave the build hanging on `get()` with no error. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P8qBB5MAGR4KYNfMWJcuCF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 importedsvelte.config.js, so those setups silently fell back to defaults, breaking source map upload paths andrewriteFramesfor custom adapterout,outDiror hooks paths.The config now comes from the SvelteKit Vite plugin's
api.options, normalized across both majors.svelte.config.jsstays as the fallback — SvelteKit only exposesapi.optionsfrom 2.62 on, so older 2.x apps still resolve through the file.Why 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.