-
-
Notifications
You must be signed in to change notification settings - Fork 258
[Bug]: HMR resets SolidJS states #5927
Description
Version
System:
OS: Linux 6.12 cpe:/o:nixos:nixos:25.05 25.05 (Warbler)
CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
Memory: 2.42 GB / 14.98 GB
Container: Yes
Shell: 5.2.37 - /nix/store/00zrahbb32nzawrmv9sjxn36h7qk9vrs-bash-5.2p37/bin/bash
Browsers:
Chromium: 138.0.7204.92
npmPackages:
@rsbuild/core: 1.4.15 => 1.4.15
@rsbuild/plugin-babel: ^1.0.6 => 1.0.6
@rsbuild/plugin-solid: ^1.0.6 => 1.0.6Details
Original rspack example works as it should - without resetting the SolidJS states (image on the left)
However, when using rsbuild example, the HMR nukes the entire app, resetting the SolidJS states (image on the right)
I'm relatively new to JS packing, yet seeing HMR working correctly in rspack exmaple but not in rsbuild one - it looks like a bug to me - if not in @rsbuild/core, then in @rsbuild/plugin-solid.
If it's not a bug at all, then how do I achieve the same HMR behaviour of rspack example in the rsbuild one?
P.S. both images show the state after file was written and HMR did its job
- for rspack - image on the left - reproduce step 2.4
- for rsbuild - image on the right - reproduce step 3.4
Reproduce link
https://github.com/mechan1sm/hmr-bug-reproduce-1
Reproduce Steps
1. Clone the repo.
git clone https://github.com/mechan1sm/hmr-bug-reproduce-12. Expected behaviour (rspack example)
2.1 Go to the rspack example directory, install and start the dev server
cd <path-to-repo>/rspack-expected
bun i && bun run dev 2.2 Go to or refresh http://localhost:3000 in your browser, and click the button few times to change the default state
2.3 Modify the src/App.jsx file (e.g. add/remove few letters after the "reload" text), save it and check if the number on the button was reset
2.4 Expected result: it wasn't reset
3. Actual behaviour (rsbuild example with src/ from rspack one)
3.1 Go to the rsbuild example directory, install and start the dev server
cd <path-to-repo>/rsbuild-actual
bun i && bun run dev3.2 Go to or refresh http://localhost:3000 in your browser, and click the button few times to change the default state
3.3 Modify the src/App.jsx file (e.g. add/remove few letters after the "reload" text), save it and check if the number on the button was reset
3.4 Actual result: it was reset