1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Move react-dom into commons.js always. (#2572)

This commit is contained in:
Arunoda Susiripala 2017-07-16 15:48:21 +05:30 committed by GitHub
parent 99dd045d1c
commit b1b0b88945

View file

@ -1,4 +1,4 @@
import { resolve, join } from 'path' import { resolve, join, sep } from 'path'
import { createHash } from 'crypto' import { createHash } from 'crypto'
import webpack from 'webpack' import webpack from 'webpack'
import glob from 'glob-promise' import glob from 'glob-promise'
@ -103,6 +103,13 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
return module.context && module.context.indexOf('node_modules') >= 0 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.
if (module.context.indexOf(`${sep}react-dom${sep}`) >= 0) {
return true
}
// 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
// used in all of the pages. Otherwise, move modules used in at-least // used in all of the pages. Otherwise, move modules used in at-least
// 1/2 of the total pages into commons. // 1/2 of the total pages into commons.