Skip to content

Commit 37d2b1a

Browse files
committed
Merge pull request webpack#1913 from ianks/master
Use better error message for when given multiple args for CommonChunks Plugin
2 parents ac45c3c + d0c6e98 commit 37d2b1a

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

lib/optimize/CommonsChunkPlugin.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55
var nextIdent = 0;
66

77
function CommonsChunkPlugin(options) {
8-
if(arguments.length > 1)
9-
throw new Error("CommonsChunkPlugin only takes one argument (pass an options object)");
8+
if(arguments.length > 1) {
9+
throw new Error("Deprecation notice: CommonsChunkPlugin now only takes a single argument. Either an options " +
10+
"object *or* the name of the chunk.\n" +
11+
"Example: if your old code looked like this:\n" +
12+
" new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')\n\n" +
13+
"You would change it to:\n" +
14+
" new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js' })\n\n" +
15+
"The available options are:\n" +
16+
" name: string\n" +
17+
" names: string[]\n" +
18+
" filename: string\n" +
19+
" minChunks: number\n" +
20+
" async: boolean\n" +
21+
" minSize: number\n");
22+
}
1023
if(Array.isArray(options) || typeof options === "string") {
1124
options = {
1225
name: options

0 commit comments

Comments
 (0)