MinChunkSizePlugin build slowly #18388
Unanswered
ganyanchuan1989
asked this question in
Q&A
Replies: 2 comments
-
Please profile your build and put it here, thank you |
Beta Was this translation helpful? Give feedback.
0 replies
-
compilation.hooks.optimizeChunks.tap(
{
name: "MinChunkSizePlugin",
stage: STAGE_ADVANCED
},
chunks => {
console.log(">> chunks", chunks.length)
const chunkGraph = compilation.chunkGraph;
const equalOptions = {
chunkOverhead: 1,
entryChunkMultiplicator: 1
};
const chunkSizesMap = new Map();
/** @type {[Chunk, Chunk][]} */
const combinations = [];
/** @type {Chunk[]} */
const smallChunks = [];
const visitedChunks = [];
for (const a of chunks) {
// check if one of the chunks sizes is smaller than the minChunkSize
// and filter pairs that can NOT be integrated!
if (chunkGraph.getChunkSize(a, equalOptions) < minChunkSize) {
smallChunks.push(a);
for (const b of visitedChunks) { // why
if (chunkGraph.canChunksBeIntegrated(b, a))
combinations.push([b, a]);
}
} else {
for (const b of smallChunks) { // why
if (chunkGraph.canChunksBeIntegrated(b, a))
combinations.push([b, a]);
}
}
chunkSizesMap.set(a, chunkGraph.getChunkSize(a, options));
visitedChunks.push(a);
}
console.log(">> combinations", combinations.length)
// long time
const sortedSizeFilteredExtendedPairCombinations = combinations.map().sort();
}) build log: >> chunks 985
>> combinations 59055 when MinChunkSizePlugin minChunkSize: 10 * 1024,log: >> chunks 985
>> combinations 229095 when MinChunkSizePlugin minChunkSize: 100 * 1024,log: >> chunks 985
>> combinations 480861 when MinChunkSizePlugin minChunkSize: 1000 * 1024,log: >> chunks 985
>> combinations 483621 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug report
What is the current behavior?
Add MinChunkSizePlugin to compile very slowly。
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
The compile time is about the same as if the MinChunkSizePlugin had not been added, or slightly increased, but the difference should not be that great
Other relevant information:
webpack version: 5.65.0
Node.js version: v14.18.1
Operating System: window 10
Additional tools: no
webpack.prod.config.js
webpack.base.conf.js
Beta Was this translation helpful? Give feedback.
All reactions