Skip to content

Commit b5a6684

Browse files
jackfranklinTheLarkInn
authored andcommitted
Refactor EntryOptionPlugin to ES2015 class (webpack#3799)
1 parent b710400 commit b5a6684

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

lib/EntryOptionPlugin.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
/*
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
4-
*/
5-
var SingleEntryPlugin = require("./SingleEntryPlugin");
6-
var MultiEntryPlugin = require("./MultiEntryPlugin");
4+
*/
5+
"use strict";
76

8-
function EntryOptionPlugin() {}
9-
module.exports = EntryOptionPlugin;
7+
const SingleEntryPlugin = require("./SingleEntryPlugin");
8+
const MultiEntryPlugin = require("./MultiEntryPlugin");
109

11-
EntryOptionPlugin.prototype.apply = function(compiler) {
12-
compiler.plugin("entry-option", function(context, entry) {
13-
function itemToPlugin(item, name) {
14-
if(Array.isArray(item))
15-
return new MultiEntryPlugin(context, item, name);
16-
else
17-
return new SingleEntryPlugin(context, item, name);
18-
}
19-
if(typeof entry === "string" || Array.isArray(entry)) {
20-
compiler.apply(itemToPlugin(entry, "main"));
21-
} else if(typeof entry === "object") {
22-
Object.keys(entry).forEach(function(name) {
23-
compiler.apply(itemToPlugin(entry[name], name));
24-
});
25-
}
26-
return true;
27-
});
28-
};
10+
module.exports = class EntryOptionPlugin {
11+
apply(compiler) {
12+
compiler.plugin("entry-option", (context, entry) => {
13+
function itemToPlugin(item, name) {
14+
if(Array.isArray(item)) {
15+
return new MultiEntryPlugin(context, item, name);
16+
} else {
17+
return new SingleEntryPlugin(context, item, name);
18+
}
19+
}
20+
if(typeof entry === "string" || Array.isArray(entry)) {
21+
compiler.apply(itemToPlugin(entry, "main"));
22+
} else if(typeof entry === "object") {
23+
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name)));
24+
}
25+
return true;
26+
});
27+
}
28+
}

0 commit comments

Comments
 (0)