Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fb1e8283
Commit
fb1e8283
authored
Mar 26, 2017
by
Arunoda Susiripala
Committed by
Guillermo Rauch
Mar 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait until webpack updates before eval the JSON page. (#1511)
parent
75028b6a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
router.js
lib/router/router.js
+16
-2
No files found.
lib/router/router.js
View file @
fb1e8283
...
...
@@ -7,6 +7,8 @@ import PQueue from '../p-queue'
import
{
loadGetInitialProps
,
getURL
}
from
'../utils'
import
{
_notifyBuildIdMismatch
}
from
'./'
const
webpackModule
=
module
if
(
typeof
window
!==
'undefined'
&&
typeof
navigator
.
serviceWorker
!==
'undefined'
)
{
navigator
.
serviceWorker
.
getRegistrations
()
.
then
(
registrations
=>
{
...
...
@@ -296,7 +298,7 @@ export default class Router {
}
const
newData
=
{
...
loadComponent
(
jsonData
),
...
await
loadComponent
(
jsonData
),
jsonPageRes
}
...
...
@@ -378,7 +380,19 @@ function toRoute (path) {
return
path
.
replace
(
/
\/
$/
,
''
)
||
'/'
}
function
loadComponent
(
jsonData
)
{
async
function
loadComponent
(
jsonData
)
{
if
(
webpackModule
&&
webpackModule
.
hot
&&
webpackModule
.
hot
.
status
()
!==
'idle'
)
{
await
new
Promise
((
resolve
)
=>
{
const
check
=
(
status
)
=>
{
if
(
status
===
'idle'
)
{
webpackModule
.
hot
.
removeStatusHandler
(
check
)
resolve
()
}
}
webpackModule
.
hot
.
status
(
check
)
})
}
const
module
=
evalScript
(
jsonData
.
component
)
const
Component
=
module
.
default
||
module
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment