You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since migrating to Vite in our Vue 2 project, we've encountered an HMR issue with Vuex:
When the store modules have circular dependencies, the store's state is reset after an HMR. I've submitted an issue here: vitejs/vite-plugin-vue2#103, but there haven't been any responses so far. Therefore, I'm attempting to find some workarounds myself.
Inspired by vitejs/vite#3301 (comment), I've created a Vite plugin to restore the store's state after an HMR:
Now the state can be restored automatically after HMR, but got new errors in the console:
hook-exec.js:1 [Vue warn]: Property or method "_isBuffer" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
found in
---> <ElMenuItem> at packages/menu/src/menu-item.vue
<ElMenuItemGroup> at packages/menu/src/menu-item-group.vue
<ElScrollbar>
<ElMenu> at packages/menu/src/menu.vue
<ElRow>
...
I found a simpler way to fix this. Add the following code in src/store/index.js:
if(import.meta.hot){// for tree-shakingimport.meta.hot.accept(['./modules/user.js',],()=>{// Not handling hot updates; the purpose is to resolve the issue where the state is reset after a hot update due to circular dependencieswindow.location.reload()},)}
Vue devtools version
6.6.4
Link to minimal reproduction
https://github.com/youthug/vite-vuex-state-repro
Steps to reproduce & screenshots
Since migrating to Vite in our Vue 2 project, we've encountered an HMR issue with Vuex:
When the store modules have circular dependencies, the store's state is reset after an HMR. I've submitted an issue here: vitejs/vite-plugin-vue2#103, but there haven't been any responses so far. Therefore, I'm attempting to find some workarounds myself.
Inspired by vitejs/vite#3301 (comment), I've created a Vite plugin to restore the store's state after an HMR:
Now the state can be restored automatically after HMR, but got new errors in the console:
How do I fix this error properly? Thanks!
What is expected?
No errors during HMR.
What is actually happening?
Errors occurred.
System Info
Any additional comments?
I have both versions of devtools but only enabled the legacy one.
The text was updated successfully, but these errors were encountered: