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
1c328a84
Unverified
Commit
1c328a84
authored
Sep 27, 2018
by
Tim Neutkens
Committed by
GitHub
Sep 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure dynamicIds are added when using function as importer (#5308)
parent
f0f82290
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
react-loadable-plugin.js
build/babel/plugins/react-loadable-plugin.js
+4
-3
dynamic.js
test/integration/basic/test/dynamic.js
+5
-0
No files found.
build/babel/plugins/react-loadable-plugin.js
View file @
1c328a84
...
...
@@ -62,15 +62,16 @@ export default function ({ types: t, template }) {
return
}
if
(
args
[
0
].
isCallExpression
())
{
if
(
args
[
0
].
isObjectExpression
())
{
options
=
args
[
0
]
}
else
{
if
(
!
args
[
1
])
{
callExpression
.
pushContainer
(
'arguments'
,
t
.
objectExpression
([]))
}
// This is needed as the code is modified above
args
=
callExpression
.
get
(
'arguments'
)
loader
=
args
[
0
]
options
=
args
[
1
]
}
else
{
options
=
args
[
0
]
}
if
(
!
options
.
isObjectExpression
())
return
...
...
test/integration/basic/test/dynamic.js
View file @
1c328a84
...
...
@@ -12,11 +12,15 @@ export default (context, render) => {
describe
(
'default behavior'
,
()
=>
{
it
(
'should render dynamic import components'
,
async
()
=>
{
const
$
=
await
get
$
(
'/dynamic/ssr'
)
// Make sure the client side knows it has to wait for the bundle
expect
(
$
(
'body'
).
html
()).
toContain
(
'"dynamicIds":["./components/hello1.js"]'
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello World 1/
)
})
it
(
'should render dynamic import components using a function as first parameter'
,
async
()
=>
{
const
$
=
await
get
$
(
'/dynamic/function'
)
// Make sure the client side knows it has to wait for the bundle
expect
(
$
(
'body'
).
html
()).
toContain
(
'"dynamicIds":["./components/hello1.js"]'
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello World 1/
)
})
...
...
@@ -52,6 +56,7 @@ export default (context, render) => {
describe
(
'ssr:false option'
,
()
=>
{
it
(
'Should render loading on the server side'
,
async
()
=>
{
const
$
=
await
get
$
(
'/dynamic/no-ssr'
)
expect
(
$
(
'body'
).
html
()).
not
.
toContain
(
'"dynamicIds"'
)
expect
(
$
(
'p'
).
text
()).
toBe
(
'loading...'
)
})
...
...
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