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
aeaccf44
Commit
aeaccf44
authored
May 15, 2017
by
Arunoda Susiripala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dynamic-import support for next-export.
parent
4d014738
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
0 deletions
+51
-0
export.js
server/export.js
+11
-0
hello.js
test/integration/static/components/hello.js
+5
-0
next.config.js
test/integration/static/next.config.js
+1
-0
dynamic-imports.js
test/integration/static/pages/dynamic-imports.js
+15
-0
index.js
test/integration/static/pages/index.js
+3
-0
browser.js
test/integration/static/test/browser.js
+11
-0
ssr.js
test/integration/static/test/ssr.js
+5
-0
No files found.
server/export.js
View file @
aeaccf44
...
@@ -44,6 +44,17 @@ export default async function (dir, options) {
...
@@ -44,6 +44,17 @@ export default async function (dir, options) {
)
)
}
}
// Copy dynamic import chunks
if
(
existsSync
(
join
(
nextDir
,
'chunks'
)))
{
log
(
' copying dynamic import chunks'
)
await
mkdirp
(
join
(
outDir
,
'_next'
,
'webpack'
))
await
cp
(
join
(
nextDir
,
'chunks'
),
join
(
outDir
,
'_next'
,
'webpack'
,
'chunks'
)
)
}
await
copyPages
(
nextDir
,
outDir
,
buildId
)
await
copyPages
(
nextDir
,
outDir
,
buildId
)
// Get the exportPathMap from the `next.config.js`
// Get the exportPathMap from the `next.config.js`
...
...
test/integration/static/components/hello.js
0 → 100644
View file @
aeaccf44
export
default
()
=>
(
<
p
>
Welcome
to
dynamic
imports
.
<
/p
>
)
test/integration/static/next.config.js
View file @
aeaccf44
...
@@ -4,6 +4,7 @@ module.exports = {
...
@@ -4,6 +4,7 @@ module.exports = {
'/'
:
{
page
:
'/'
},
'/'
:
{
page
:
'/'
},
'/about'
:
{
page
:
'/about'
},
'/about'
:
{
page
:
'/about'
},
'/counter'
:
{
page
:
'/counter'
},
'/counter'
:
{
page
:
'/counter'
},
'/dynamic-imports'
:
{
page
:
'/dynamic-imports'
},
'/dynamic'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'cool dynamic text'
}
},
'/dynamic'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'cool dynamic text'
}
},
'/dynamic/one'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'next export is nice'
}
},
'/dynamic/one'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'next export is nice'
}
},
'/dynamic/two'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'zeit is awesome'
}
}
'/dynamic/two'
:
{
page
:
'/dynamic'
,
query
:
{
text
:
'zeit is awesome'
}
}
...
...
test/integration/static/pages/dynamic-imports.js
0 → 100644
View file @
aeaccf44
import
Link
from
'next/link'
import
dynamic
from
'next/dynamic'
const
DynamicComponent
=
dynamic
(
import
(
'../components/hello'
))
export
default
()
=>
(
<
div
id
=
'dynamic-imports-page'
>
<
div
>
<
Link
href
=
'/'
>
<
a
>
Go
Back
<
/a
>
<
/Link
>
<
/div
>
<
DynamicComponent
/>
<
/div
>
)
test/integration/static/pages/index.js
View file @
aeaccf44
...
@@ -45,6 +45,9 @@ export default () => (
...
@@ -45,6 +45,9 @@ export default () => (
<
Link
href
=
'/level1/about'
>
<
Link
href
=
'/level1/about'
>
<
a
id
=
'level1-about-page'
>
Level1
about
page
<
/a
>
<
a
id
=
'level1-about-page'
>
Level1
about
page
<
/a
>
<
/Link
>
<
/Link
>
<
Link
href
=
'/dynamic-imports'
>
<
a
id
=
'dynamic-imports-page'
>
Dynamic
imports
page
<
/a
>
<
/Link
>
<
/div
>
<
/div
>
<
p
>
This
is
the
home
page
<
/p
>
<
p
>
This
is
the
home
page
<
/p
>
<
style
jsx
>
{
`
<
style
jsx
>
{
`
...
...
test/integration/static/test/browser.js
View file @
aeaccf44
...
@@ -93,6 +93,17 @@ export default function (context) {
...
@@ -93,6 +93,17 @@ export default function (context) {
browser
.
close
()
browser
.
close
()
})
})
it
(
'should render dynamic import components in the client'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
port
,
'/'
)
const
text
=
await
browser
.
elementByCss
(
'#dynamic-imports-page'
).
click
()
.
waitForElementByCss
(
'#dynamic-imports-page'
)
.
elementByCss
(
'#dynamic-imports-page p'
).
text
()
expect
(
text
).
toBe
(
'Welcome to dynamic imports.'
)
browser
.
close
()
})
describe
(
'pages in the nested level: level1'
,
()
=>
{
describe
(
'pages in the nested level: level1'
,
()
=>
{
it
(
'should render the home page'
,
async
()
=>
{
it
(
'should render the home page'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
port
,
'/'
)
const
browser
=
await
webdriver
(
context
.
port
,
'/'
)
...
...
test/integration/static/test/ssr.js
View file @
aeaccf44
...
@@ -17,5 +17,10 @@ export default function (context) {
...
@@ -17,5 +17,10 @@ export default function (context) {
const
html
=
await
renderViaHTTP
(
context
.
port
,
'/dynamic/one'
)
const
html
=
await
renderViaHTTP
(
context
.
port
,
'/dynamic/one'
)
expect
(
html
).
toMatch
(
/next export is nice/
)
expect
(
html
).
toMatch
(
/next export is nice/
)
})
})
it
(
'should render pages with dynamic imports'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
context
.
port
,
'/dynamic-imports'
)
expect
(
html
).
toMatch
(
/Welcome to dynamic imports./
)
})
})
})
}
}
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