Widdershin / cycle-restart

Swap out the code in your Cycle.js apps on the fly!
MIT License
123 stars 11 forks source link

module.hot.accept callback not invoked? #37

Closed ronag closed 8 years ago

ronag commented 8 years ago

Following the example but using the following command line:

budo index.js:bundle.js -d public -- -t babelify -p browserify-hmr

"Reloading" is never printed:

if (module.hot) {
  module.hot.accept('./src/app', () => {
    console.log('Reloading')
    const app = require('./src/app').default
    restart(app, drivers, { sinks, sources }, isolate)
  })
}

However, in the browser log it prints:

[HMR] Updated modules ["src/components/hub/browser/asset.js", "src/components/hub/browser/grid.js", "src/components/hub/browser/index.js", "src/components/hub/index.js", "src/app.js"]

Any ideas what I might be doing wrong?

averyvery commented 7 years ago

Did you ever resolve this issue? Having a similar one.

wyqydsyq commented 7 years ago

This seems to be an issue with HMR rather than cycle-restart.

cycle-restart is only concerned with restoring your application state when your .accept() callback reruns your Cycle instance (restart()).

If the accept callback itself isn't behaving as expected then that's an issue with the HMR client library or how it is being used. console.logging out from the accept callback in the example included with this library logs out fine so I'm unable to reproduce this.

Widdershin commented 7 years ago

@averyvery Could you provide the full source code of the file that is calling module.hot.accept?

averyvery commented 7 years ago

Apologies, I think I actually commented on the wrong issue while a lot of tabs were open. What I was seeing wasn't related to this library at all.