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
ac7a23d5
Unverified
Commit
ac7a23d5
authored
Mar 21, 2018
by
Tim Neutkens
Committed by
GitHub
Mar 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure react and react-dom are bundled to main.js in development (#4039)
Signed-off-by:
Tim Neutkens
<
timneutkens@me.com
>
parent
1844a090
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
webpack.js
server/build/webpack.js
+9
-3
No files found.
server/build/webpack.js
View file @
ac7a23d5
...
@@ -253,11 +253,11 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
...
@@ -253,11 +253,11 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
isServer
&&
new
NextJsSsrImportPlugin
(),
isServer
&&
new
NextJsSsrImportPlugin
(),
// In dev mode, we don't move anything to the commons bundle.
// In dev mode, we don't move anything to the commons bundle.
// In production we move common modules into the existing main.js bundle
// In production we move common modules into the existing main.js bundle
!
dev
&&
!
isServer
&&
new
webpack
.
optimize
.
CommonsChunkPlugin
({
!
isServer
&&
new
webpack
.
optimize
.
CommonsChunkPlugin
({
name
:
'main.js'
,
name
:
'main.js'
,
filename
:
'main.js'
,
filename
:
'main.js'
,
minChunks
(
module
,
count
)
{
minChunks
(
module
,
count
)
{
//
react
//
React and React DOM are used everywhere in Next.js. So they should always be common. Even in development mode, to speed up compilation.
if
(
module
.
resource
&&
module
.
resource
.
includes
(
`
${
sep
}
react-dom
${
sep
}
`
)
&&
count
>=
0
)
{
if
(
module
.
resource
&&
module
.
resource
.
includes
(
`
${
sep
}
react-dom
${
sep
}
`
)
&&
count
>=
0
)
{
return
true
return
true
}
}
...
@@ -265,7 +265,13 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
...
@@ -265,7 +265,13 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
if
(
module
.
resource
&&
module
.
resource
.
includes
(
`
${
sep
}
react
${
sep
}
`
)
&&
count
>=
0
)
{
if
(
module
.
resource
&&
module
.
resource
.
includes
(
`
${
sep
}
react
${
sep
}
`
)
&&
count
>=
0
)
{
return
true
return
true
}
}
// react end
// In the dev we use on-demand-entries.
// So, it makes no sense to use commonChunks based on the minChunks count.
// Instead, we move all the code in node_modules into each of the pages.
if
(
dev
)
{
return
false
}
// commons
// commons
// If there are one or two pages, only move modules to common if they are
// If there are one or two pages, only move modules to common if they are
...
...
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