Skip to content

Commit 060cac3

Browse files
arunodarauchg
authored andcommitted
Move all the modules used in 1/2 of all pages into the common chunks. (vercel#1659)
1 parent 0007cd2 commit 060cac3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

server/build/webpack.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
3636
const mainJS = dev
3737
? require.resolve('../../client/next-dev') : require.resolve('../../client/next')
3838

39-
let minChunks
39+
let totalPages
4040

4141
const entry = async () => {
4242
const entries = {
@@ -68,8 +68,7 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
6868
}
6969
}
7070

71-
// calculate minChunks of CommonsChunkPlugin for later use
72-
minChunks = Math.max(2, pages.filter((p) => p !== documentPage).length)
71+
totalPages = pages.filter((p) => p !== documentPage).length
7372

7473
return entries
7574
}
@@ -101,9 +100,8 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
101100
return module.context && module.context.indexOf('node_modules') >= 0
102101
}
103102

104-
// NOTE: it depends on the fact that the entry funtion is always called
105-
// before applying CommonsChunkPlugin
106-
return count >= minChunks
103+
// Move modules used in at-least 1/2 of the total pages into commons.
104+
return count >= totalPages * 0.5
107105
}
108106
}),
109107
// This chunk contains all the webpack related code. So, all the changes

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy