Closed benkingcode closed 5 years ago
I use koajs instead of expressjs
import http from 'http'
import Loadable from 'react-loadable'
import app from './server'
let currentApp = app.callback()
Loadable.preloadAll()
.then(() => {
const server = http.createServer(currentApp)
server.listen(PORT, HOST, () => console.log(`🚀 started on ${HOST}:${PORT}`))
if (module.hot) {
console.log('✅ Server-side HMR Enabled!')
module.hot.accept('./server', () => {
console.log('🔁 HMR Reloading `./server`...')
server.removeListener('request', currentApp)
console.log("after `removeListener`", server.listeners("request").length)
currentApp = require('./server').default.callback()
server.on('request', currentApp)
})
}
})
.catch(console.error)
@olegreznichenko I'm also running into this issue. So basically just changing to koa will solve HMR?
I was able to make HMR work with the with-react-loadable example @dbbk where you able to make it work?
I could not make it work too with a fresh install.
I had to add this to make it work in the client.js
:
if (module.hot) {
module.hot.accept('./App', window.main);
}
I also did the same thing @hrasoa!
if (module.hot) {
module.hot.accept('./App.jsx', () => window.main());
}
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.
I've cloned the razzle source and tried running the
with-react-loadable
example, but it seems like HMR no longer works. I'm not sure what the problem is here, does anyone have an idea how to get it working again?