posva / unplugin-vue-router

Next Generation file based typed routing for Vue Router
https://uvr.esm.is
MIT License
1.47k stars 67 forks source link

0.9.0 broke HMR #414

Closed mseeley closed 1 month ago

mseeley commented 1 month ago

The change from server.ws.send to server.hot.send has broken HMR.

https://github.com/posva/unplugin-vue-router/blame/d60101cb607e42a3642f72c415adc3e9c0159390/src/core/vite/index.ts#L16

https://github.com/posva/unplugin-vue-router/commit/c98ddbf33a824b48aacdcd649e3b5b676c0df8c1 looks like a WIP. Was it meant to go directly into main?

[dev:vite              ]
[dev:vite              ]   VITE v4.4.11  ready in 506 ms
[dev:vite              ]
[dev:vite              ]   ➜  Local:   http://localhost:3210/
[dev:vite              ]   ➜  Network: use --host to expose
[dev:vite              ]   ➜  press h to show help
[dev:vite              ] file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/unplugin-vue-router@0.9.0_rollup@4.0.2_vue-router@4.3.2_vue@3.4.27/node_modules/unplugin-vue-router/dist/chunk-UFHUCJVX.js:1463
[dev:vite              ]     server.hot.send({
[dev:vite              ]                ^
[dev:vite              ]
[dev:vite              ] TypeError: Cannot read properties of undefined (reading 'send')
[dev:vite              ]     at Object.updateRoutes (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/unplugin-vue-router@0.9.0_rollup@4.0.2_vue-router@4.3.2_vue@3.4.27/node_modules/unplugin-vue-router/dist/chunk-UFHUCJVX.js:1463:16)
[dev:vite              ]     at Object.generateRoutes (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/unplugin-vue-router@0.9.0_rollup@4.0.2_vue-router@4.3.2_vue@3.4.27/node_modules/unplugin-vue-router/dist/chunk-UFHUCJVX.js:1377:15)
[dev:vite              ]     at Context.load (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/unplugin-vue-router@0.9.0_rollup@4.0.2_vue-router@4.3.2_vue@3.4.27/node_modules/unplugin-vue-router/dist/chunk-UFHUCJVX.js:1559:20)
[dev:vite              ]     at plugin.load (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/unplugin@1.10.1/node_modules/unplugin/dist/index.mjs:1484:20)
[dev:vite              ]     at Object.load (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/vite@4.4.11_@types+node@20.11.16_sass@1.62.1/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:44316:64)
[dev:vite              ]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[dev:vite              ]     at async loadAndTransform (file:///Users/komodo/Development/komodo-book/node_modules/.pnpm/vite@4.4.11_@types+node@20.11.16_sass@1.62.1/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:54943:24)
[dev:vite              ]
[dev:vite              ] Node.js v20.11.1
[dev:vite              ]  ELIFECYCLE  Command failed with exit code 1.
[dev:typed-scss-modules]  ELIFECYCLE  Command failed.
[dev:typed-scss-modules]  ELIFECYCLE  Command failed.
mseeley commented 1 month ago

Changing createViteContext to use server.ws instead of server.hot restored functionality

posva commented 1 month ago

I see, this API is new in Vite 5, I changed it because of the deprecation message

posva commented 1 month ago

Apparently they deprecated hot now, so going back to ws will work for both vite versions ✨

mseeley commented 1 month ago

Thank you very much @posva!