mirror of https://github.com/webpack/webpack.git
Merge pull request #5458 from samccone/sjs/remove-function-redeclare
Remove function redeclaration.
This commit is contained in:
commit
0059bcf241
|
|
@ -8,20 +8,21 @@ const SingleEntryPlugin = require("./SingleEntryPlugin");
|
|||
const MultiEntryPlugin = require("./MultiEntryPlugin");
|
||||
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
|
||||
|
||||
function itemToPlugin(context, item, name) {
|
||||
if(Array.isArray(item)) {
|
||||
return new MultiEntryPlugin(context, item, name);
|
||||
} else {
|
||||
return new SingleEntryPlugin(context, item, name);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = class EntryOptionPlugin {
|
||||
apply(compiler) {
|
||||
compiler.plugin("entry-option", (context, entry) => {
|
||||
function itemToPlugin(item, name) {
|
||||
if(Array.isArray(item)) {
|
||||
return new MultiEntryPlugin(context, item, name);
|
||||
} else {
|
||||
return new SingleEntryPlugin(context, item, name);
|
||||
}
|
||||
}
|
||||
if(typeof entry === "string" || Array.isArray(entry)) {
|
||||
compiler.apply(itemToPlugin(entry, "main"));
|
||||
compiler.apply(itemToPlugin(context, entry, "main"));
|
||||
} else if(typeof entry === "object") {
|
||||
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name)));
|
||||
Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(context, entry[name], name)));
|
||||
} else if(typeof entry === "function") {
|
||||
compiler.apply(new DynamicEntryPlugin(context, entry));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue