sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.75k stars 1.95k forks source link

`@hmr` directives no longer work #12985

Closed TheFireBlast closed 1 week ago

TheFireBlast commented 1 week ago

Describe the bug

In previous versions of SvelteKit, one could preserve local component state using certain directives inside comments, these being // @hmr:keep (used before or beside a variable declaration) and // @hmr:keep-all (which applies to all variables). Currently, these directives are no longer respected even though the documentation still references them, and there is no notice I could find saying this behavior would be removed.

svelte-hmr

I believe this is caused by the dropping of svelte-hmr in favor of having hmr built into Svelte 5, which seems to not have implemented this feature, so, sorry in advance if I were actually supposed to have opened this issue in the svelte repo instead.

Reproduction

OLD: https://stackblitz.com/edit/stackblitz-starters-tbnujh?file=src%2Froutes%2F%2Bpage.svelte CURRENT: https://stackblitz.com/edit/sveltejs-kit-template-default-ncwrwc?file=src%2Froutes%2F%2Bpage.svelte

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz
    Memory: 643.30 MB / 7.91 GB
  Binaries:
    Node: 20.15.0 - ~\AppData\Local\pnpm\node.EXE
    npm: 10.7.0 - ~\AppData\Local\pnpm\npm.CMD
    pnpm: 9.12.3 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    @sveltejs/adapter-auto: ^3.3.1 => 3.3.1
    @sveltejs/kit: ^2.8.0 => 2.8.0
    @sveltejs/vite-plugin-svelte: 4.0.0-next.7 => 4.0.0-next.7
    svelte: ^5.1.13 => 5.1.13
    vite: ^5.4.10 => 5.4.10

Severity

annoyance

Additional Information

No response

benmccann commented 1 week ago

I've sent a PR to remove that FAQ since it was so outdated. If those are features that you were relying on, I'd suggest filing a feature request over at https://github.com/sveltejs/svelte/issues