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

Svelte 5 HMR removes extra properties added to component instance after mount() #14885

Open
Mtn-View opened this issue Jan 3, 2025 · 1 comment

Comments

@Mtn-View
Copy link

Mtn-View commented Jan 3, 2025

Describe the bug

Abstract State Router / Svelte State Renderer render the Svelte component, and then add extra properties on the component instance to later use in other parts of the lifecycle.

In Svelte 4, triggering HMR on one of these components worked fine, and the extra properties stayed intact. In Svelte 5, they get removed, and this breaks the router after HMR. Reloading the page fixes this issue, but I'd prefer to keep using HMR in Svelte 5.

I also posted about this in the Svelte discord, if you want more context: https://discord.com/channels/457912077277855764/1323699302073372843

Reproduction

https://github.com/Mtn-View/svelte-5-hmr-issue

  • git clone
  • npm i
  • npx vite
  • Change App.svelte and save to trigger HMR
  • Click one of the links on the page, and you will get the error.

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) 7 150U
    Memory: 3.06 GB / 15.70 GB
  Binaries:
    Node: 20.18.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.15.2 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.63)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    svelte: ^5.15.0 => 5.16.1

Severity

annoyance

@trueadm
Copy link
Contributor

trueadm commented Jan 5, 2025

This is an incompatibility with svelte-state-renderer and abstract-state-router in the fact they are using internals around how HMR worked in Svelte 3/4. This is no longer supported in Svelte 5, so we recommend speaking to the library author to upgrade support for Svelte 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants