Commit 6477492f authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by GitHub

Move NPM modules out of the commons chunk in dev mode. (#2716)

This is only a dev feature and it removes an error in HMR.
Otherwise it'll throw an error with undefined error in the webpack core.
parent 256f9dc7
......@@ -94,14 +94,6 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
name: 'commons',
filename: 'commons.js',
minChunks (module, count) {
// 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 this chunk.
// With that, we could gain better performance for page-rebuild process.
if (dev) {
return module.context && module.context.indexOf('node_modules') >= 0
}
// We need to move react-dom explicitly into common chunks.
// Otherwise, if some other page or module uses it, it might
// included in that bundle too.
......@@ -109,6 +101,13 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
return true
}
// 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
}
// If there are one or two pages, only move modules to common if they are
// used in all of the pages. Otherwise, move modules used in at-least
// 1/2 of the total pages into commons.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment