9baee888af
Just cleans up some code, doesn't change the underlying mechanism ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. ## Documentation / Examples - [ ] Make sure the linting passes
31 lines
774 B
JavaScript
31 lines
774 B
JavaScript
import connect from './error-overlay/hot-dev-client'
|
|
|
|
export default () => {
|
|
const devClient = connect()
|
|
|
|
devClient.subscribeToHmrEvent((obj) => {
|
|
if (obj.action === 'reloadPage') {
|
|
return window.location.reload()
|
|
}
|
|
if (obj.action === 'removedPage') {
|
|
const [page] = obj.data
|
|
if (page === window.next.router.pathname) {
|
|
return window.location.reload()
|
|
}
|
|
return
|
|
}
|
|
if (obj.action === 'addedPage') {
|
|
const [page] = obj.data
|
|
if (
|
|
page === window.next.router.pathname &&
|
|
typeof window.next.router.components[page] === 'undefined'
|
|
) {
|
|
return window.location.reload()
|
|
}
|
|
return
|
|
}
|
|
throw new Error('Unexpected action ' + obj.action)
|
|
})
|
|
|
|
return devClient
|
|
}
|