From cbacdf11bf8a1e6f35f738e7b1fcd3dac4083061 Mon Sep 17 00:00:00 2001 From: Xiao <784487301@qq.com> Date: Mon, 11 Aug 2025 23:10:06 +0800 Subject: [PATCH] fix: adjust the timing for adding Group when depending on runtimeChunk --- lib/Compilation.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index bac1c2163..74ed7def4 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -3261,6 +3261,23 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o } } + buildChunkGraph(this, chunkGraphInit); + this.hooks.afterChunks.call(this.chunks); + this.logger.timeEnd("create chunks"); + + this.logger.time("optimize"); + this.hooks.optimize.call(); + + while (this.hooks.optimizeModules.call(this.modules)) { + /* empty */ + } + this.hooks.afterOptimizeModules.call(this.modules); + + while (this.hooks.optimizeChunks.call(this.chunks, this.chunkGroups)) { + /* empty */ + } + this.hooks.afterOptimizeChunks.call(this.chunks, this.chunkGroups); + for (const [ name, { @@ -3280,22 +3297,6 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o } } } - buildChunkGraph(this, chunkGraphInit); - this.hooks.afterChunks.call(this.chunks); - this.logger.timeEnd("create chunks"); - - this.logger.time("optimize"); - this.hooks.optimize.call(); - - while (this.hooks.optimizeModules.call(this.modules)) { - /* empty */ - } - this.hooks.afterOptimizeModules.call(this.modules); - - while (this.hooks.optimizeChunks.call(this.chunks, this.chunkGroups)) { - /* empty */ - } - this.hooks.afterOptimizeChunks.call(this.chunks, this.chunkGroups); this.hooks.optimizeTree.callAsync(this.chunks, this.modules, (err) => { if (err) {