webpack-hot-middleware icon indicating copy to clipboard operation
webpack-hot-middleware copied to clipboard

Force reload when server has restarted

Open binarykitchen opened this issue 8 years ago • 4 comments

When you have restarted the dev server and aren't using the reload option, you always can see these warnings in the dev console

[HMR] Cannot find update (Full reload needed)
[HMR] (Probably because of restarting the server)

for better DX, I would probably force reload the browser regardless. As default or with a new option, whatever.

An attempted workaround would be something ugly like

    module.hot.addStatusHandler((status) => {
      if (status === 'idle') {
        window.location.reload()
      }
    })

But no, that's too bad and causes too many reloads.

binarykitchen avatar Nov 22 '17 00:11 binarykitchen

I think if you set the client option reload=true, that is what happens?

glenjamin avatar Nov 22 '17 07:11 glenjamin

Nope, I dont want to set that reload option. Because I need the module.hot.accept() API which wouldn't work then the whole page always gets reloaded.

But my issue is that, when the dev server has restarted, the page doesn't get reloaded when you haven't set the reload option although I want it to reload, only for this situation, nothing else.

binarykitchen avatar Nov 22 '17 20:11 binarykitchen

Then the reload option is unclear, and possibly needs better documentation.

Reload means that if hot reloading cannot be applied, the page will be reloaded. If hot reloading can be applied, the page will not be reloaded.

glenjamin avatar Nov 22 '17 20:11 glenjamin

Hmmm, yeah, that sounds like documentation needs to be clearer. Few more questions

  1. What does "If hot reloading can be applied" exactly mean?
  2. What are typical use cases when you do not want to apply reload=true

binarykitchen avatar Nov 22 '17 20:11 binarykitchen