From c8617e06e6125533299734bfb96efe31b238e815 Mon Sep 17 00:00:00 2001 From: Walker Burgin Date: Fri, 10 Aug 2018 08:49:48 -0700 Subject: [PATCH 1/3] Add orderable --- types/webpack-chain/index.d.ts | 17 +++++++++++++++-- types/webpack-chain/webpack-chain-tests.ts | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/types/webpack-chain/index.d.ts b/types/webpack-chain/index.d.ts index 691e4be9b9..033ef9951f 100644 --- a/types/webpack-chain/index.d.ts +++ b/types/webpack-chain/index.d.ts @@ -85,10 +85,14 @@ declare namespace Config { class Plugins extends TypedChainedMap> {} - class Plugin extends ChainedMap { + class Plugin extends ChainedMap implements Orderable { init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this; use(plugin: PluginClass, args?: any[]): this; tap(f: (args: any[]) => any[]): this; + + // Orderable + before(name: string): this; + after(name: string): this; } class Module extends ChainedMap { @@ -231,11 +235,15 @@ declare namespace Config { interface LoaderOptions { [name: string]: any; } - class Use extends ChainedMap { + class Use extends ChainedMap implements Orderable { loader(value: string): this; options(value: LoaderOptions): this; tap(f: (options: LoaderOptions) => LoaderOptions): this; + + // Orderable + before(name: string): this; + after(name: string): this; } type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' | @@ -255,4 +263,9 @@ declare namespace Config { interface PluginClass { new (...opts: any[]): webpack.Plugin; } + + interface Orderable { + before(name: string): this; + after(name: string): this; + } } diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index 8775fec7f9..e61cd4e304 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -46,8 +46,20 @@ config .use(webpack.DefinePlugin, []) .end() + .plugin('bar') + .use(webpack.DefinePlugin, []) + .before('foo') + .end() + + .plugin('baz') + .use(webpack.DefinePlugin, []) + .after('bar') + .end() + .plugins .delete('foo') + .delete('bar') + .delete('baz') .end() .devServer @@ -113,6 +125,14 @@ config .pre() .post() .end() + .rule('lint') + .test(/.js$/) + .use('eslint') + .loader('eslint-loader') + .options({}) + .after('compile') + .end() + .end() .rules .delete('compile') .end() From 3221d9567c1359e6a701674131edea8608481ea4 Mon Sep 17 00:00:00 2001 From: Walker Burgin Date: Fri, 10 Aug 2018 08:52:20 -0700 Subject: [PATCH 2/3] Fix tests --- types/webpack-chain/webpack-chain-tests.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index e61cd4e304..ffeeba1248 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -119,19 +119,17 @@ config .loader('babel-loader') .options({}) .end() - .uses - .delete('babel') - .end() - .pre() - .post() - .end() - .rule('lint') - .test(/.js$/) .use('eslint') .loader('eslint-loader') .options({}) .after('compile') .end() + .uses + .delete('babel') + .delete('eslint') + .end() + .pre() + .post() .end() .rules .delete('compile') From dee63e3c68dcc887549fd227be95ba6a27396ba9 Mon Sep 17 00:00:00 2001 From: Walker Burgin Date: Fri, 10 Aug 2018 08:54:30 -0700 Subject: [PATCH 3/3] Fix tests --- types/webpack-chain/webpack-chain-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack-chain/webpack-chain-tests.ts b/types/webpack-chain/webpack-chain-tests.ts index ffeeba1248..f1d0daa5e2 100644 --- a/types/webpack-chain/webpack-chain-tests.ts +++ b/types/webpack-chain/webpack-chain-tests.ts @@ -122,7 +122,7 @@ config .use('eslint') .loader('eslint-loader') .options({}) - .after('compile') + .after('babel') .end() .uses .delete('babel')