提交 649071ec 编写于 作者: Q qiang

fix: optimization.subPackages support webpack5 #3723

上级 3f9211c2
......@@ -89,8 +89,8 @@ module.exports = function getSplitChunks () {
}
if (module.resource && (
module.resource.indexOf('.vue') !== -1 ||
module.resource.indexOf('.nvue') !== -1 ||
normalizePath(module.resource).indexOf(mainPath) === 0 // main.js
module.resource.indexOf('.nvue') !== -1 ||
normalizePath(module.resource).indexOf(mainPath) === 0 // main.js
)) {
return false
}
......@@ -120,6 +120,15 @@ module.exports = function getSplitChunks () {
}
return true
}
function getModuleChunks (module, chunks) {
// webpack5
if ('chunkGraph' in chunks) {
chunks = chunks.chunkGraph.getModuleChunks(module)
}
return chunks
}
// TODO 独立分包
const cacheGroups = {
......@@ -130,6 +139,7 @@ module.exports = function getSplitChunks () {
if (!baseTest(module)) {
return false
}
chunks = getModuleChunks(module, chunks)
const matchSubPackages = findSubPackages(chunks)
const matchSubPackagesCount = matchSubPackages.size
const isMainPackage = ( // 非分包 或 两个及以上分包 或 主包内有使用
......@@ -210,6 +220,7 @@ module.exports = function getSplitChunks () {
if (!baseTest(module)) {
return false
}
chunks = getModuleChunks(module, chunks)
const matchSubPackages = findSubPackages(chunks)
if (
matchSubPackages.size === 1 &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册