Skip to content

Commit 6bc6fcd

Browse files
committed
Merge pull request webpack#1120 from kennyt/documentation
Add argument error handling for optimization plugins
2 parents ebabcfd + d0611d0 commit 6bc6fcd

7 files changed

Lines changed: 16 additions & 3 deletions

lib/optimize/AggressiveMergingPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Author Tobias Koppers @sokra
44
*/
55
function AggressiveMergingPlugin(options) {
6+
if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
7+
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");
8+
}
69
this.options = options || {};
710
}
811
module.exports = AggressiveMergingPlugin;

lib/optimize/LimitChunkCountPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Author Tobias Koppers @sokra
44
*/
55
function LimitChunkCountPlugin(options) {
6+
if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
7+
throw new Error("Argument should be an options object.\nFor more info on options, see http://webpack.github.io/docs/list-of-plugins.html");
8+
}
69
this.options = options || {};
710
}
811
module.exports = LimitChunkCountPlugin;

lib/optimize/MinChunkSizePlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Author Tobias Koppers @sokra
44
*/
55
function MinChunkSizePlugin(options) {
6+
if(typeof options !== "object" || Array.isArray(options)) {
7+
throw new Error("Argument should be an options object.\nFor more info on options, see http://webpack.github.io/docs/list-of-plugins.html");
8+
}
69
this.options = options;
710
}
811
module.exports = MinChunkSizePlugin;

lib/optimize/OccurrenceOrderPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Author Tobias Koppers @sokra
44
*/
55
function OccurrenceOrderPlugin(preferEntry) {
6+
if(preferEntry !== undefined && typeof preferEntry !== "boolean") {
7+
throw new Error("Argument should be a boolean.\nFor more info on this plugin, see http://webpack.github.io/docs/list-of-plugins.html");
8+
}
69
this.preferEntry = preferEntry;
710
}
811
module.exports = OccurrenceOrderPlugin;

test/Integration.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("Integration", function() {
5252
alias: { should: require.resolve("should") }
5353
},
5454
plugins: [
55-
new webpack.optimize.LimitChunkCountPlugin(1),
55+
new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}),
5656
new webpack.DefinePlugin({
5757
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
5858
CONST_TRUE: true,

test/NodeTemplatePlugin.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("NodeTemplatePlugin", function() {
5050
},
5151
entry: "./entry",
5252
plugins: [
53-
new webpack.optimize.LimitChunkCountPlugin(1),
53+
new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}),
5454
new webpack.optimize.UglifyJsPlugin()
5555
]
5656
}, function(err, stats) {

test/browsertest/library2config.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports =
1414
alias:
1515
should: require.resolve "should"
1616
plugins: [
17-
new webpack.optimize.LimitChunkCountPlugin 2
17+
new webpack.optimize.LimitChunkCountPlugin
18+
maxChunks: 2
1819
new webpack.DefinePlugin
1920
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
2021
CONST_UNDEFINED: undefined,

0 commit comments

Comments
 (0)