preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.72k stars 91 forks source link

Vite HMR not working #339

Closed MichaelGradek closed 1 year ago

MichaelGradek commented 1 year ago

HMR is not triggered on file changes when using @preact/signals-react

Vite does seem to detect the code changed as the console line keeping count of changes does increase:

8:27:13 PM [vite] hmr update /src/App.tsx (x35)

However, the changes in code / UI do not get updated.

As soon as I switch back to react's useState it starts working again.

package.json

{
  "name": "test",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@preact/signals-react": "^1.2.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@vitejs/plugin-react-swc": "^3.0.0",
    "typescript": "^4.9.3",
    "vite": "^4.2.0"
  }
}
pupudu commented 1 year ago

Happens with webpack HMR as well

rschristian commented 1 year ago

Duplicate of #250