1

tl;dr HMR working everywhere except for imported pinia store refs.

I have a fairly basic Vue3 + vite + pinia site, and I'm trying to get hot module replacement (HMR) working for store values. Whenever I modify a ref on a component *.vue file directly and use it in it's template, it's updating the page. However, if it's a ref from a pinia store, I have to manually refresh the page for the change to be reflected.

Some things I've tried:

UPDATE: So from the last bullet, pinia issue 843 apparently that's expected behavior, but I can't get it to work even with the comment -> change -> uncomment that they mentioned. I didn't really understand their explanation, if anyone can expand on it would really appreciate it!

Note: The functionality of the page isn't the issue, if the store is updated through user input, the page does update as you'd expect, this is just about getting HMR to work through the store. Also, it doesn't generalize to any *.js file imported; with composables, for instance, HMR works fine. Likewise with other variables, etc imported from *.js files.


Details:

    "pinia": "^2.0.36",
    "vue": "^3.2.25",
    "vite": "^2.9.9",
PhysRex
  • 184
  • 2
  • 7
  • 1
    upgrade your dependencies, i have "vite": "^4.2.1" for example – Alexander Nenashev May 19 '23 at 07:47
  • 1
    The store state is not reset if you make a change to its source. It's the expected behavior (state is persisted across components and across HMR updates). You might want to consider this a bug, other developers might consider resetting the state on every change to source would be a bug. Bottom line: It's the intended behavior and it's not going to change. Btw, it's HMR, not HRM. – tao May 19 '23 at 10:23

0 Answers0