Skip to content

Commit 9a1eca5

Browse files
committed
Optimize RemoveEmptyChunksPlugin
1 parent 9a72294 commit 9a1eca5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/optimize/RemoveEmptyChunksPlugin.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ class RemoveEmptyChunksPlugin {
88
apply(compiler) {
99
compiler.hooks.compilation.tap("RemoveEmptyChunksPlugin", compilation => {
1010
const handler = chunks => {
11-
chunks
12-
.filter(
13-
chunk =>
14-
chunk.isEmpty() && !chunk.hasRuntime() && !chunk.hasEntryModule()
15-
)
16-
.forEach(chunk => {
17-
chunk.remove("empty");
18-
chunks.splice(chunks.indexOf(chunk), 1);
19-
});
11+
for (let i = chunks.length - 1; i >= 0; i--) {
12+
const chunk = chunks[i];
13+
if (
14+
chunk.isEmpty() &&
15+
!chunk.hasRuntime() &&
16+
!chunk.hasEntryModule()
17+
) {
18+
chunks.splice(i, 1);
19+
}
20+
}
2021
};
2122
compilation.hooks.optimizeChunksBasic.tap(
2223
"RemoveEmptyChunksPlugin",

0 commit comments

Comments
 (0)