File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import PQueue from '../p-queue'
7
7
import { loadGetInitialProps , getURL } from '../utils'
8
8
import { _notifyBuildIdMismatch } from './'
9
9
10
+ const webpackModule = module
11
+
10
12
if ( typeof window !== 'undefined' && typeof navigator . serviceWorker !== 'undefined' ) {
11
13
navigator . serviceWorker . getRegistrations ( )
12
14
. then ( registrations => {
@@ -296,7 +298,7 @@ export default class Router {
296
298
}
297
299
298
300
const newData = {
299
- ...loadComponent ( jsonData ) ,
301
+ ...await loadComponent ( jsonData ) ,
300
302
jsonPageRes
301
303
}
302
304
@@ -378,7 +380,19 @@ function toRoute (path) {
378
380
return path . replace ( / \/ $ / , '' ) || '/'
379
381
}
380
382
381
- function loadComponent ( jsonData ) {
383
+ async function loadComponent ( jsonData ) {
384
+ if ( webpackModule && webpackModule . hot && webpackModule . hot . status ( ) !== 'idle' ) {
385
+ await new Promise ( ( resolve ) => {
386
+ const check = ( status ) => {
387
+ if ( status === 'idle' ) {
388
+ webpackModule . hot . removeStatusHandler ( check )
389
+ resolve ( )
390
+ }
391
+ }
392
+ webpackModule . hot . status ( check )
393
+ } )
394
+ }
395
+
382
396
const module = evalScript ( jsonData . component )
383
397
const Component = module . default || module
384
398
You can’t perform that action at this time.
0 commit comments