From 4990f2dcfa676ea0b1b1f3b92c3edaa0b2e7897e Mon Sep 17 00:00:00 2001 From: Benjamin Lim Date: Mon, 6 Feb 2017 11:10:04 +0800 Subject: [PATCH] refactor: move PerformanceOptions into Options namespace --- webpack/index.d.ts | 45 +++++++++++++++++++++++----------------- webpack/webpack-tests.ts | 2 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 43ced0bce5..e03b95328d 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -66,7 +66,7 @@ declare namespace webpack { /** Stats options for logging */ stats?: compiler.StatsToStringOptions; /** Performance options */ - performance?: PerformanceOptions; + performance?: Options.Performance; } interface Entry { @@ -468,6 +468,29 @@ declare namespace webpack { } type Rule = LoaderRule | UseRule | RulesRule | OneOfRule; + namespace Options { + interface Performance { + /** This property allows webpack to control what files are used to calculate performance hints. */ + assetFilter?(assetFilename: string): boolean; + /** + * Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are + * found. This property is set to "warning" by default. + */ + hints?: 'warning' | 'error' | boolean; + /** + * An asset is any emitted file from webpack. This option controls when webpack emits a performance hint + * based on individual asset size. The default value is 250000 (bytes). + */ + maxAssetSize?: number; + /** + * An entrypoint represents all assets that would be utilized during initial load time for a specific entry. + * This option controls when webpack should emit performance hints based on the maximum entrypoint size. + * The default value is 250000 (bytes). + */ + maxEntrypointSize?: number; + } + } + interface Plugin extends tapable.Plugin { apply(thisArg: Webpack, ...args: any[]): void; } @@ -1102,24 +1125,8 @@ declare namespace webpack { type CompilerCallback = (err: Error, stats: Stats) => void; } - interface PerformanceOptions { - /** - * Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are found. This property is set to "warning" by default. - */ - hints?: boolean | 'error' | 'warning'; - /** - * An entrypoint represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entrypoint size. The default value is 250000 (bytes). - */ - maxEntrypointSize?: number; - /** - * An asset is any emitted file from webpack. This option controls when webpack emits a performance hint based on individual asset size. The default value is 250000 (bytes). - */ - maxAssetSize?: number; - /** - * This property allows webpack to control what files are used to calculate performance hints. - */ - assetFilter?: (assetFilename: string) => boolean; - } + /** @deprecated use webpack.Options.Performance */ + type PerformanceOptions = webpack.Options.Performance; } declare var webpack: webpack.Webpack; diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 4ed9fc3b31..51da9aaad4 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -524,7 +524,7 @@ const resolve: webpack.Resolve = { cachePredicate: 'boo' // why does this test _not_ fail!? } -const performance: webpack.PerformanceOptions = { +const performance: webpack.Options.Performance = { hints: 'error', maxEntrypointSize: 400000, maxAssetSize: 100000,