Unverified Commit 9d699cb1 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix dev router usage before router initializing (#31632)

parent e212167f
......@@ -4,6 +4,8 @@ import initOnDemandEntries from './on-demand-entries-client'
import { addMessageListener, connectHMR } from './error-overlay/websocket'
const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent)
window.__NEXT_DATA__ = data
let { assetPrefix, page } = data
assetPrefix = assetPrefix || ''
let mostRecentHash = null
......
......@@ -35,7 +35,6 @@ import {
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { addMessageListener } from './websocket'
import formatWebpackMessages from './format-webpack-messages'
import Router from 'next/router'
// This alternative WebpackDevServer combines the functionality of:
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
......@@ -57,7 +56,7 @@ export default function connect() {
try {
processMessage(event)
} catch (ex) {
console.warn('Invalid HMR message: ' + event.data + '\n' + ex)
console.warn('Invalid HMR message: ' + event.data + '\n', ex)
}
})
......@@ -91,7 +90,7 @@ function handleSuccess() {
const isHotUpdate =
!isFirstCompilation ||
(Router.pathname !== '/_error' && isUpdateAvailable())
(window.__NEXT_DATA__.page !== '/_error' && isUpdateAvailable())
isFirstCompilation = false
hasCompileErrors = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment