Add argument error handling in optimization plugins

This commit is contained in:
Kenny Tran 2015-05-27 09:46:47 -07:00
parent bac9b48bfb
commit 7a080e6f24
4 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,9 @@
Author Tobias Koppers @sokra
*/
function AggressiveMergingPlugin(options) {
if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
throw new Error("Argument should be an options object. To use defaults, pass in nothing.\nFor more info on options, see http://webpack.github.io/docs/list-of-plugins.html");
}
this.options = options || {};
}
module.exports = AggressiveMergingPlugin;

View File

@ -3,6 +3,9 @@
Author Tobias Koppers @sokra
*/
function LimitChunkCountPlugin(options) {
if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
throw new Error("Argument should be an options object.\nFor more info on options, see http://webpack.github.io/docs/list-of-plugins.html");
}
this.options = options || {};
}
module.exports = LimitChunkCountPlugin;

View File

@ -3,6 +3,9 @@
Author Tobias Koppers @sokra
*/
function MinChunkSizePlugin(options) {
if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
throw new Error("Argument should be an options object.\nFor more info on options, see http://webpack.github.io/docs/list-of-plugins.html");
}
this.options = options;
}
module.exports = MinChunkSizePlugin;

View File

@ -3,6 +3,9 @@
Author Tobias Koppers @sokra
*/
function OccurrenceOrderPlugin(preferEntry) {
if(preferEntry !== undefined && typeof preferEntry !== "boolean") {
throw new Error("Argument should be a boolean.\nFor more info on this plugin, see http://webpack.github.io/docs/list-of-plugins.html");
}
this.preferEntry = preferEntry;
}
module.exports = OccurrenceOrderPlugin;