Skip to content

Commit 6cad87f

Browse files
authored
refactor(es6): Upgrade NamedModulesPlugin to es6 (webpack#3619)
1 parent 79791a5 commit 6cad87f

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

lib/NamedModulesPlugin.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function NamedModulesPlugin(options) {
6-
this.options = options || {};
5+
"use strict";
6+
7+
class NamedModulesPlugin {
8+
constructor(options) {
9+
this.options = options || {};
10+
}
11+
12+
apply(compiler) {
13+
compiler.plugin("compilation", (compilation) => {
14+
compilation.plugin("before-module-ids", (modules) => {
15+
modules.forEach((module) => {
16+
if(module.id === null && module.libIdent) {
17+
module.id = module.libIdent({
18+
context: this.options.context || compiler.options.context
19+
});
20+
}
21+
});
22+
});
23+
});
24+
}
725
}
26+
827
module.exports = NamedModulesPlugin;
9-
NamedModulesPlugin.prototype.apply = function(compiler) {
10-
compiler.plugin("compilation", function(compilation) {
11-
compilation.plugin("before-module-ids", function(modules) {
12-
modules.forEach(function(module) {
13-
if(module.id === null && module.libIdent) {
14-
module.id = module.libIdent({
15-
context: this.options.context || compiler.options.context
16-
});
17-
}
18-
}, this);
19-
}.bind(this));
20-
}.bind(this));
21-
};

0 commit comments

Comments
 (0)