Subscribe on changes!

HMR does not work unless component has an active instance

avatar
Oct 7th 2021

Version

3.2.19

Reproduction link

github.com

Steps to reproduce

Reproduction steps in ElMassimo/vite-vue-router-hmr-repro

What is expected?

HMR should work for any components that have been imported in the current page.

What is actually happening?

A regression was introduced in 3.2.11. 3.2.10 behaves as expected.

HMR only works if the component has an active instance.


Most users experience this issue when using vue-router, as no full reload occurs, and is not unusual to navigate between pages.

It can happen in different scenarios, for example, a component that is conditionally displayed. If the user modifies the component file when the condition is false, and then the condition becomes true, the rendered component is outdated and won't reflect current changes until a page reload or another HMR update is sent.

avatar
Oct 7th 2021

Since plugin-vue is still providing _sfc_main as a second parameter to the HMR createRecord function, it's likely that only changes to vue-next are needed.

avatar
Oct 7th 2021

@yyx990803 Confirmed that this is a regression, it was working in 3.2.10.

avatar
Oct 8th 2021

Works like a charm in 3.2.20, thanks!