Skip to content

Commit a133c90

Browse files
shubhekshaTheLarkInn
authored andcommitted
refactor(ES6) upgrade RemoveEmptyChunksPlugin to ES6 (webpack#3765)
* refactor(ES6): upgrade RemoveEmptyChunksPlugin to ES6
1 parent 9cf2adb commit a133c90

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/optimize/RemoveEmptyChunksPlugin.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function RemoveEmptyChunksPlugin() {}
6-
module.exports = RemoveEmptyChunksPlugin;
5+
"use strict";
6+
7+
class RemoveEmptyChunksPlugin {
78

8-
RemoveEmptyChunksPlugin.prototype.apply = function(compiler) {
9-
compiler.plugin("compilation", function(compilation) {
10-
compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], function(chunks) {
11-
chunks.filter(function(chunk) {
12-
return chunk.isEmpty() && !chunk.hasRuntime() && !chunk.hasEntryModule();
13-
}).forEach(function(chunk) {
14-
chunk.remove("empty");
15-
chunks.splice(chunks.indexOf(chunk), 1);
9+
apply(compiler) {
10+
compiler.plugin("compilation", (compilation) => {
11+
compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
12+
chunks.filter((chunk) => chunk.isEmpty() && !chunk.hasRuntime() && !chunk.hasEntryModule())
13+
.forEach((chunk) => {
14+
chunk.remove("empty");
15+
chunks.splice(chunks.indexOf(chunk), 1);
16+
});
1617
});
1718
});
18-
});
19-
};
19+
}
20+
}
21+
module.exports = RemoveEmptyChunksPlugin;

0 commit comments

Comments
 (0)