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
8e2c199e
Unverified
Commit
8e2c199e
authored
Jul 26, 2018
by
Tim Neutkens
Committed by
GitHub
Jul 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dynamic import page navigation (#4842)
Fixes #3775
parent
f4988e7f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
0 deletions
+38
-0
.babelrc
.babelrc
+1
-0
next-dev.js
client/next-dev.js
+6
-0
noop.js
client/noop.js
+0
-0
hello.js
test/integration/ondemand/components/hello.js
+1
-0
dynamic.js
test/integration/ondemand/pages/nav/dynamic.js
+7
-0
index.js
test/integration/ondemand/pages/nav/index.js
+5
-0
index.test.js
test/integration/ondemand/test/index.test.js
+18
-0
No files found.
.babelrc
View file @
8e2c199e
...
...
@@ -5,6 +5,7 @@
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
...
...
client/next-dev.js
View file @
8e2c199e
...
...
@@ -2,6 +2,12 @@ import initNext, * as next from './'
import
initOnDemandEntries
from
'./on-demand-entries-client'
import
initWebpackHMR
from
'./webpack-hot-middleware-client'
// Temporary workaround for the issue described here:
// https://github.com/zeit/next.js/issues/3775#issuecomment-407438123
// 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
import
(
'./noop'
)
const
{
__NEXT_DATA__
:
{
assetPrefix
...
...
client/noop.js
0 → 100644
View file @
8e2c199e
test/integration/ondemand/components/hello.js
0 → 100644
View file @
8e2c199e
export
default
()
=>
<
p
>
Hello
<
/p
>
test/integration/ondemand/pages/nav/dynamic.js
0 → 100644
View file @
8e2c199e
import
dynamic
from
'next/dynamic'
const
Hello
=
dynamic
(
import
(
'../../components/hello.js'
))
export
default
()
=>
<
div
className
=
'dynamic-page'
>
<
Hello
/>
<
/div
>
test/integration/ondemand/pages/nav/index.js
0 → 100644
View file @
8e2c199e
import
Link
from
'next/link'
export
default
()
=>
<
div
>
<
Link
href
=
'/nav/dynamic'
><
a
id
=
'to-dynamic'
>
To
dynamic
import
<
/a></
Link
>
<
/div
>
test/integration/ondemand/test/index.test.js
View file @
8e2c199e
/* global jasmine, describe, beforeAll, afterAll, it, expect */
import
{
join
,
resolve
}
from
'path'
import
{
existsSync
}
from
'fs'
import
webdriver
from
'next-webdriver'
import
{
renderViaHTTP
,
findPort
,
...
...
@@ -57,4 +58,21 @@ describe('On Demand Entries', () => {
if
(
!
existsSync
(
indexPagePath
))
return
}
})
it
(
'should navigate to pages with dynamic imports'
,
async
()
=>
{
let
browser
try
{
browser
=
await
webdriver
(
context
.
appPort
,
'/nav'
)
const
text
=
await
browser
.
elementByCss
(
'#to-dynamic'
).
click
()
.
waitForElementByCss
(
'.dynamic-page'
)
.
elementByCss
(
'p'
).
text
()
expect
(
text
).
toBe
(
'Hello'
)
}
finally
{
if
(
browser
)
{
browser
.
close
()
}
}
})
})
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