HMR reloads whole app, loosing all state. #1846
-
I create the minimal app with index.js and mod.js extending it to mod1.js and mod2.js . When I change any file, HRM reloads everything, the html file and all js files, so all state is left the app is completely refreshed. Is there a barebones (framework less) example that demos hrm working in a way such that state is preserved? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Snowpack implements the ESM-HMR standard which is defined here. As illustrated in the examples you need to call |
Beta Was this translation helpful? Give feedback.
-
Very helpful, danke Florian ;) |
Beta Was this translation helpful? Give feedback.
Snowpack implements the ESM-HMR standard which is defined here. As illustrated in the examples you need to call
import.meta.hot.accept
to receive updated modules and have to take care to apply them to your app including state restoration. If none of your modules explicitly handles the update, Snowpack falls back to a page refresh.