2020-01-09 21:31:28 +01:00
|
|
|
/* globals __REPLACE_NOOP_IMPORT__ */
|
2017-10-14 19:20:49 +02:00
|
|
|
import initNext, * as next from './'
|
2019-06-05 20:15:42 +02:00
|
|
|
import EventSourcePolyfill from './dev/event-source-polyfill'
|
|
|
|
import initOnDemandEntries from './dev/on-demand-entries-client'
|
|
|
|
import initWebpackHMR from './dev/webpack-hot-middleware-client'
|
|
|
|
import initializeBuildWatcher from './dev/dev-build-watcher'
|
2019-07-03 02:42:41 +02:00
|
|
|
import initializePrerenderIndicator from './dev/prerender-indicator'
|
2020-01-09 21:31:28 +01:00
|
|
|
import { displayContent } from './dev/fouc'
|
2018-01-30 16:40:52 +01:00
|
|
|
|
2018-07-26 12:38:45 +02:00
|
|
|
// Temporary workaround for the issue described here:
|
2020-05-27 23:51:11 +02:00
|
|
|
// https://github.com/vercel/next.js/issues/3775#issuecomment-407438123
|
2018-07-26 12:38:45 +02:00
|
|
|
// The runtimeChunk doesn't have dynamic import handling code when there hasn't been a dynamic import
|
|
|
|
// The runtimeChunk can't hot reload itself currently to correct it when adding pages using on-demand-entries
|
2020-01-09 21:31:28 +01:00
|
|
|
// eslint-disable-next-line no-unused-expressions
|
|
|
|
__REPLACE_NOOP_IMPORT__
|
2018-07-26 12:38:45 +02:00
|
|
|
|
2019-02-22 16:23:58 +01:00
|
|
|
// Support EventSource on Internet Explorer 11
|
|
|
|
if (!window.EventSource) {
|
|
|
|
window.EventSource = EventSourcePolyfill
|
|
|
|
}
|
|
|
|
|
2018-07-24 11:24:40 +02:00
|
|
|
const {
|
2019-11-11 04:24:53 +01:00
|
|
|
__NEXT_DATA__: { assetPrefix },
|
2018-07-24 11:24:40 +02:00
|
|
|
} = window
|
|
|
|
|
|
|
|
const prefix = assetPrefix || ''
|
2019-02-19 22:45:07 +01:00
|
|
|
const webpackHMR = initWebpackHMR({ assetPrefix: prefix })
|
2017-01-12 02:58:20 +01:00
|
|
|
|
2018-07-24 11:24:40 +02:00
|
|
|
window.next = next
|
|
|
|
initNext({ webpackHMR })
|
2020-06-03 17:58:58 +02:00
|
|
|
.then(({ renderCtx, render }) => {
|
2019-02-19 22:45:07 +01:00
|
|
|
initOnDemandEntries({ assetPrefix: prefix })
|
2019-09-15 23:18:11 +02:00
|
|
|
if (process.env.__NEXT_BUILD_INDICATOR) initializeBuildWatcher()
|
|
|
|
if (
|
|
|
|
process.env.__NEXT_PRERENDER_INDICATOR &&
|
|
|
|
// disable by default in electron
|
|
|
|
!(typeof process !== 'undefined' && 'electron' in process.versions)
|
|
|
|
) {
|
|
|
|
initializePrerenderIndicator()
|
|
|
|
}
|
2017-04-18 06:18:43 +02:00
|
|
|
|
2020-01-20 21:41:41 +01:00
|
|
|
// delay rendering until after styles have been applied in development
|
|
|
|
displayContent(() => {
|
|
|
|
render(renderCtx)
|
|
|
|
})
|
2019-05-29 13:57:26 +02:00
|
|
|
})
|
2020-05-18 21:24:37 +02:00
|
|
|
.catch((err) => {
|
2018-07-24 11:24:40 +02:00
|
|
|
console.error('Error was not caught', err)
|
2017-04-18 06:18:43 +02:00
|
|
|
})
|