SvelteKit: Only disable SSR when building, not serving #21290
Merged
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.
Closes #21053
What I did
In #20804 we disabled SSR because Storybook can't be built with SSR enabled.
That broke HMR, so now we're only disabling SSR at build time, not when serving.
I'm unsure why it broke HMR, but it's not SvelteKit related, as it also breaks HMR to add that disable-SSR plugin to a plain Svelte-Vite project.
It looks like the Svelte Vite plugin is using the SSR setting to handle HMR differently, so maybe that's the culprit.
https://github.com/sveltejs/vite-plugin-svelte/blob/main/packages/vite-plugin-svelte/src/handle-hot-update.ts#L61-L65
How to test
yarn task --task sandbox --start-from auto --template svelte-kit/skeleton-ts
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]