Skip to content

Commit 0059bcf

Browse files
authored
Merge pull request webpack#5458 from samccone/sjs/remove-function-redeclare
Remove function redeclaration.
2 parents a2601c3 + 8b3772d commit 0059bcf

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎lib/EntryOptionPlugin.js‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ const SingleEntryPlugin = require("./SingleEntryPlugin");
88
const MultiEntryPlugin = require("./MultiEntryPlugin");
99
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
1010

11+
function itemToPlugin(context, item, name) {
12+
if(Array.isArray(item)) {
13+
return new MultiEntryPlugin(context, item, name);
14+
} else {
15+
return new SingleEntryPlugin(context, item, name);
16+
}
17+
}
18+
1119
module.exports = class EntryOptionPlugin {
1220
apply(compiler) {
1321
compiler.plugin("entry-option", (context, entry) => {
14-
function itemToPlugin(item, name) {
15-
if(Array.isArray(item)) {
16-
return new MultiEntryPlugin(context, item, name);
17-
} else {
18-
return new SingleEntryPlugin(context, item, name);
19-
}
20-
}
2122
if(typeof entry === "string" || Array.isArray(entry)) {
22-
compiler.apply(itemToPlugin(entry, "main"));
23+
compiler.apply(itemToPlugin(context, entry, "main"));
2324
} else if(typeof entry === "object") {
24-
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name)));
25+
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(context, entry[name], name)));
2526
} else if(typeof entry === "function") {
2627
compiler.apply(new DynamicEntryPlugin(context, entry));
2728
}

0 commit comments

Comments
 (0)