Skip to content

Commit 5f6029f

Browse files
aemTheLarkInn
authored andcommitted
refactor(es6): refactor IgnorePlugin to ES6 class (webpack#3638)
1 parent 7327ee6 commit 5f6029f

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

lib/IgnorePlugin.js

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,37 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function IgnorePlugin(resourceRegExp, contextRegExp) {
6-
this.resourceRegExp = resourceRegExp;
7-
this.contextRegExp = contextRegExp;
8-
}
9-
module.exports = IgnorePlugin;
10-
IgnorePlugin.prototype.apply = function(compiler) {
11-
var resourceRegExp = this.resourceRegExp;
12-
var contextRegExp = this.contextRegExp;
13-
compiler.plugin("normal-module-factory", function(nmf) {
14-
nmf.plugin("before-resolve", function(result, callback) {
15-
if(!result) return callback();
16-
if(resourceRegExp.test(result.request) &&
17-
(!contextRegExp || contextRegExp.test(result.context))) {
18-
return callback();
19-
}
20-
return callback(null, result);
5+
"use strict";
6+
7+
class IgnorePlugin {
8+
constructor(resourceRegExp, contextRegExp) {
9+
this.resourceRegExp = resourceRegExp;
10+
this.contextRegExp = contextRegExp;
11+
}
12+
13+
apply(compiler) {
14+
let resourceRegExp = this.resourceRegExp;
15+
let contextRegExp = this.contextRegExp;
16+
compiler.plugin("normal-module-factory", (nmf) => {
17+
nmf.plugin("before-resolve", (result, callback) => {
18+
if(!result) return callback();
19+
if(resourceRegExp.test(result.request) &&
20+
(!contextRegExp || contextRegExp.test(result.context))) {
21+
return callback();
22+
}
23+
return callback(null, result);
24+
});
2125
});
22-
});
23-
compiler.plugin("context-module-factory", function(cmf) {
24-
cmf.plugin("before-resolve", function(result, callback) {
25-
if(!result) return callback();
26-
if(resourceRegExp.test(result.request)) {
27-
return callback();
28-
}
29-
return callback(null, result);
26+
compiler.plugin("context-module-factory", (cmf) => {
27+
cmf.plugin("before-resolve", (result, callback) => {
28+
if(!result) return callback();
29+
if(resourceRegExp.test(result.request)) {
30+
return callback();
31+
}
32+
return callback(null, result);
33+
});
3034
});
31-
});
32-
};
35+
}
36+
}
37+
38+
module.exports = IgnorePlugin;

0 commit comments

Comments
 (0)