Skip to content
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

SvelteKit: Only disable SSR when building, not serving #21290

Merged
merged 2 commits into from
Feb 28, 2023

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Feb 28, 2023

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

  1. Create a SvelteKit sandbox with yarn task --task sandbox --start-from auto --template svelte-kit/skeleton-ts
  2. Start it and open a story.
  3. Make changes to the story, and see that they are reflected in the UI.
  4. Make changes to the component, and see that they are reflected in the UI.
  5. Build the Storybook to ensure it can still be built.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@JReinhold JReinhold linked an issue Feb 28, 2023 that may be closed by this pull request
@JReinhold JReinhold requested review from IanVS and benmccann February 28, 2023 11:29
@JReinhold JReinhold self-assigned this Feb 28, 2023
Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

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

This is so bizzare, but good find. I'd lean towards considering it a vite or plugin-svelte issue, but this seems like a good workaround.

code/frameworks/sveltekit/src/plugins/config-overrides.ts Outdated Show resolved Hide resolved
@JReinhold
Copy link
Contributor Author

This is so bizzare, but good find. I'd lean towards considering it a vite or plugin-svelte issue, but this seems like a good workaround.

I agree, I'll see if I can build a non-Storybook repro and file an issue over there.

@JReinhold JReinhold merged commit 9e4ab66 into next Feb 28, 2023
@JReinhold JReinhold deleted the 21053-bug-hmr-not-working-on-sveltekit-and-storybook branch February 28, 2023 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: HMR not working on SvelteKit and Storybook
2 participants