From ce8ec50aab62c4d226d9ec61bcda989d5394c9ec Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Mon, 13 Feb 2017 18:00:28 +0800 Subject: [PATCH 1/7] Update BannerPlugin definition Fix webpack/lib/BannerPlugin.js:19 Error: BannerPlugin only takes one argument (pass an options object) --- webpack/index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 8b5a4d9938..f07630d869 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -654,7 +654,14 @@ declare namespace webpack { */ class BannerPlugin extends Plugin { - constructor(banner: any, options: any); + constructor(options: { + banner: string, + raw?: boolean, + entryOnly?: boolean, + test?: string | RegExp | Array, + include?: string | RegExp | Array, + exclude?: string | RegExp | Array + }); } class ContextReplacementPlugin extends Plugin { From affaaeb107d29ca122cd29568748a14264c62821 Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Mon, 13 Feb 2017 18:46:39 +0800 Subject: [PATCH 2/7] Add myself to `Definitions by` --- webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index f07630d869..696968719c 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for webpack 2.2 // Project: https://github.com/webpack/webpack -// Definitions by: Qubo , Matt Lewis , Benjamin Lim , Boris Cherny +// Definitions by: Qubo , Matt Lewis , Benjamin Lim , Boris Cherny , Tommy Troy Lin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 592b7f26f90dc6013c43e9be2b0966fc11dbc42a Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Mon, 13 Feb 2017 19:15:26 +0800 Subject: [PATCH 3/7] Update tests --- webpack/webpack-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index ffa69e90f2..7c47089e13 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -257,7 +257,7 @@ plugin = new webpack.IgnorePlugin(requestRegExp, contextRegExp); plugin = new webpack.PrefetchPlugin(context, request); plugin = new webpack.PrefetchPlugin(request); -plugin = new webpack.BannerPlugin(banner, options); +plugin = new webpack.BannerPlugin({ banner: 'banner' }); plugin = new webpack.optimize.DedupePlugin(); plugin = new webpack.optimize.LimitChunkCountPlugin(options); plugin = new webpack.optimize.MinChunkSizePlugin(options); From ad6ef1cd46e2011b0e17415d7857dabbe1424f64 Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Tue, 14 Feb 2017 15:54:42 +0800 Subject: [PATCH 4/7] Update to comply with @bumbleblym' s suggestions --- webpack/index.d.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 696968719c..9b80258479 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -654,14 +654,20 @@ declare namespace webpack { */ class BannerPlugin extends Plugin { - constructor(options: { - banner: string, - raw?: boolean, - entryOnly?: boolean, - test?: string | RegExp | Array, - include?: string | RegExp | Array, - exclude?: string | RegExp | Array - }); + constructor(options?: BannerPlugin.Options | string); + } + + namespace BannerPlugin { + type Filter = string | RegExp; + + interface Options { + banner?: string; + entryOnly?: boolean; + exclude?: Filter | Filter[]; + include?: Filter | Filter[]; + raw?: boolean; + test?: Filter | Filter[]; + } } class ContextReplacementPlugin extends Plugin { From ddc2a2f922fec2f872996106ca49f53e7f3fa82e Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Tue, 14 Feb 2017 16:00:05 +0800 Subject: [PATCH 5/7] Update webpack-tests.ts --- webpack/webpack-tests.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 7c47089e13..9e07985544 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -257,7 +257,17 @@ plugin = new webpack.IgnorePlugin(requestRegExp, contextRegExp); plugin = new webpack.PrefetchPlugin(context, request); plugin = new webpack.PrefetchPlugin(request); -plugin = new webpack.BannerPlugin({ banner: 'banner' }); +plugin = new webpack.BannerPlugin('banner'); +plugin = new webpack.BannerPlugin(); +plugin = new webpack.BannerPlugin({}); +plugin = new webpack.BannerPlugin({ + banner: 'banner', + entryOnly: true, + exclude: /index/, + include: 'test', + raw: false, + test: ['test', /index/] +}); plugin = new webpack.optimize.DedupePlugin(); plugin = new webpack.optimize.LimitChunkCountPlugin(options); plugin = new webpack.optimize.MinChunkSizePlugin(options); From e4454f702e65b4ed8bf43802f5357f4d8b1753ab Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Tue, 14 Feb 2017 16:40:09 +0800 Subject: [PATCH 6/7] Update index.d.ts --- webpack/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 9b80258479..da30f1151e 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -654,14 +654,14 @@ declare namespace webpack { */ class BannerPlugin extends Plugin { - constructor(options?: BannerPlugin.Options | string); + constructor(options: string | BannerPlugin.Options); } namespace BannerPlugin { type Filter = string | RegExp; - + interface Options { - banner?: string; + banner: string; entryOnly?: boolean; exclude?: Filter | Filter[]; include?: Filter | Filter[]; From d3b1b0ea6661c51baca622dac37dd1ca550d65f8 Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Tue, 14 Feb 2017 16:41:34 +0800 Subject: [PATCH 7/7] Update webpack-tests.ts --- webpack/webpack-tests.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 9e07985544..d3f38e469e 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -258,8 +258,9 @@ plugin = new webpack.IgnorePlugin(requestRegExp, contextRegExp); plugin = new webpack.PrefetchPlugin(context, request); plugin = new webpack.PrefetchPlugin(request); plugin = new webpack.BannerPlugin('banner'); -plugin = new webpack.BannerPlugin(); -plugin = new webpack.BannerPlugin({}); +plugin = new webpack.BannerPlugin({ + banner: 'banner' +}); plugin = new webpack.BannerPlugin({ banner: 'banner', entryOnly: true,