Update webpack ProgressPlugin definition, to support both object/function options (#43375)

* Update webpack ProgressPlugin definition, to support both options of object and function.

* Re-order webpack.ProgressPlugin parameter ordering to trigger CI.

* Tune webpack ProgressPlugin definition for current v4 version, and also add comments.

* Fix webpack ProgressPlugin default value comment for current v4 version, and also update handler function interface according to official document.
This commit is contained in:
Dion Shi
2020-03-29 14:03:30 +01:00
committed by GitHub
parent f385d82f5a
commit 7caeca4bfb
2 changed files with 42 additions and 1 deletions
+40 -1
View File
@@ -21,6 +21,7 @@
// Felix Haus <https://github.com/ofhouse>
// Daniel Chin <https://github.com/danielthank>
// Daiki Ihara <https://github.com/sasurau4>
// Dion Shi <https://github.com/dionshihk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -1832,7 +1833,45 @@ declare namespace webpack {
}
class ProgressPlugin extends Plugin {
constructor(options?: (percentage: number, msg: string, moduleProgress?: string, activeModules?: string, moduleName?: string) => void);
constructor(options?: ProgressPlugin.Options | ProgressPlugin.Handler);
}
namespace ProgressPlugin {
/**
* A handler function which will be called when webpack hooks report progress
*/
type Handler = (percentage: number, msg: string, ...args: string[]) => void;
interface Options {
/**
* Show active modules count and one active module in progress message
* Default: true
*/
activeModules?: boolean;
/**
* Show entries count in progress message
* Default: false
*/
entries?: boolean;
/**
* Function that executes for every progress step
*/
handler?: Handler;
/**
* Show modules count in progress message
* Default: true
*/
modules?: boolean;
/**
* Minimum modules count to start with, only for mode = modules
* Default: 500
*/
modulesCount?: number;
/**
* Collect profile data for progress steps
* Default: false
*/
profile?: boolean | null;
}
}
class EnvironmentPlugin extends Plugin {
+2
View File
@@ -508,6 +508,8 @@ plugin = new webpack.EnvironmentPlugin(['a', 'b']);
plugin = new webpack.EnvironmentPlugin({ a: true, b: 'c' });
plugin = new webpack.ProgressPlugin((percent: number, message: string) => { });
plugin = new webpack.ProgressPlugin((percent: number, message: string, moduleProgress?: string, activeModules?: string, moduleName?: string) => { });
plugin = new webpack.ProgressPlugin({ profile: true });
plugin = new webpack.ProgressPlugin({ activeModules: true, entries: false });
plugin = new webpack.HashedModuleIdsPlugin();
plugin = new webpack.HashedModuleIdsPlugin({
hashFunction: 'sha256',