diff --git a/lib/flow-typed/npm/webpack_v5.x.x.js b/lib/flow-typed/npm/webpack_v5.x.x.js --- a/lib/flow-typed/npm/webpack_v5.x.x.js +++ b/lib/flow-typed/npm/webpack_v5.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 029c45f838294c42f5621a2fbc0e2222 -// flow-typed version: d55f290df6/webpack_v5.x.x/flow_>=v0.104.x +// flow-typed signature: 1ba8ade30b849c0d757d83265696dc84 +// flow-typed version: f7fd492eb0/webpack_v5.x.x/flow_>=v0.104.x declare module 'webpack' { import typeof { Server } from 'http'; @@ -13,11 +13,34 @@ declare type WebpackError = $WebpackError; + declare type WebpackLogger = {| + getChildLogger: (arg0: string | (() => string)) => WebpackLogger, + error(...args: $ReadOnlyArray): void, + warn(...args: $ReadOnlyArray): void, + info(...args: $ReadOnlyArray): void, + log(...args: $ReadOnlyArray): void, + debug(...args: $ReadOnlyArray): void, + assert(assertion: any, ...args: $ReadOnlyArray): void, + trace(): void, + clear(): void, + status(...args: $ReadOnlyArray): void, + group(...args: $ReadOnlyArray): void, + groupCollapsed(...args: $ReadOnlyArray): void, + groupEnd(...args: $ReadOnlyArray): void, + profile(label?: any): void, + profileEnd(label?: any): void, + time(label?: any): void, + timeLog(label?: any): void, + timeEnd(label?: any): void, + timeAggregate(label?: any): void, + timeAggregateEnd(label?: any): void, + |}; + declare interface Stats { hasErrors(): boolean; hasWarnings(): boolean; toJson(options?: StatsOptions): any; - toString(options?: { ...StatsOptions, colors?: boolean, ... }): string; + toString(options?: { ...StatsOptionsObject, colors?: boolean, ... }): string; } declare type Callback = (error: WebpackError, stats: Stats) => void; @@ -192,11 +215,10 @@ declare type WebpackPluginFunction = (compiler: WebpackCompiler) => void; - declare type WebpackPluginInstance = { - [k: string]: any, - apply: WebpackPluginFunction, - ... - }; + declare interface WebpackPluginInstance { + apply: WebpackPluginFunction; + [k: string]: any; + } declare type OptimizationSplitChunksOptions = { automaticNameDelimiter?: string, @@ -378,10 +400,7 @@ declare type FilterTypes = FilterItemTypes | Array; - declare type StatsOptions = - | boolean - | ('none' | 'errors-only' | 'minimal' | 'normal' | 'detailed' | 'verbose') - | { + declare type StatsOptionsObject = { all?: boolean, assets?: boolean, assetsSort?: string, @@ -436,6 +455,11 @@ ... }; + declare type StatsOptions = + | boolean + | ('none' | 'errors-only' | 'minimal' | 'normal' | 'detailed' | 'verbose') + | StatsOptionsObject; + declare type WatchOptions = { aggregateTimeout?: number, ignored?: { [k: string]: any, ... }, @@ -613,27 +637,18 @@ }; declare class EnvironmentPlugin { - constructor(env: { [string]: mixed, ... } | string[]): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + constructor(env: { [string]: mixed, ... } | string[]): $NonMaybeType[number]; } declare class DefinePlugin { - constructor({ [string]: string, ... }): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + constructor({ [string]: string, ... }): $NonMaybeType[number]; } declare class IgnorePlugin { constructor(RegExp | {| resourceRegExp: RegExp, contextRegExp?: RegExp, - |}, void | RegExp): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + |}, void | RegExp): $NonMaybeType[number]; } declare class SourceMapDevToolPlugin { @@ -656,27 +671,114 @@ noSources?: ?boolean, publicPath?: ?string, fileContext?: ?string, - |}): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + |}): $NonMaybeType[number]; } declare class HotModuleReplacementPlugin { - constructor(): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + constructor(): $NonMaybeType[number]; } declare class ContextReplacementPlugin { constructor( resourceRegExp: RegExp, newContentRegExp?: RegExp - ): $ElementType< - $NonMaybeType<$PropertyType>, - number - >; + ): $NonMaybeType[number]; + } + + declare type ProgressHandler = (percentage: number, msg: string, ...args: $ReadOnlyArray) => void; + + /** + * Options object for the ProgressPlugin. + */ + declare type ProgressPluginOptions = {| + /** + * Show active modules count and one active module in progress message. + */ + activeModules?: boolean, + + /** + * Show dependencies count in progress message. + */ + dependencies?: boolean, + + /** + * Minimum dependencies count to start with. For better progress calculation. Default: 10000. + */ + dependenciesCount?: number, + + /** + * Show entries count in progress message. + */ + entries?: boolean, + + /** + * Function that executes for every progress step. + */ + handler?: ProgressHandler, + + /** + * Show modules count in progress message. + */ + modules?: boolean, + + /** + * Minimum modules count to start with. For better progress calculation. Default: 5000. + */ + modulesCount?: number, + + /** + * Collect percent algorithm. By default it calculates by a median from modules, entries and dependencies percent. + */ + percentBy?: null | "entries" | "modules" | "dependencies", + + /** + * Collect profile data for progress steps. Default: false. + */ + profile?: null | boolean, + |}; + + declare type ProgressPluginArgument = + | ProgressPluginOptions + | ProgressHandler; + + declare class ProgressPlugin { + constructor(options?: ProgressPluginArgument): $NonMaybeType[number]; + profile?: null | boolean; + handler?: (percentage: number, msg: string, ...args: $ReadOnlyArray) => void; + modulesCount?: number; + dependenciesCount?: number; + showEntries?: boolean; + showModules?: boolean; + showDependencies?: boolean; + showActiveModules?: boolean; + percentBy?: null | "entries" | "modules" | "dependencies"; + apply(compiler: WebpackCompiler | WebpackMultiCompiler): void; + static getReporter( + compiler: WebpackCompiler + ): void | ((p: number, ...args: $ReadOnlyArray) => void); + static defaultOptions: {| + profile: boolean; + modulesCount: number; + dependenciesCount: number; + modules: boolean; + dependencies: boolean; + activeModules: boolean; + entries: boolean; + |}; + static createDefaultHandler: ( + profile: void | null | boolean, + logger: WebpackLogger + ) => (percentage: number, msg: string, ...args: $ReadOnlyArray) => void; + } + + declare class ProvidePlugin { + constructor(definitions: { [key: string]: string | string[] }): $NonMaybeType[number]; + definitions: { [key: string]: string | string[] }; + + /** + * Apply the plugin + */ + apply(compiler: WebpackCompiler | WebpackMultiCompiler): void; } declare function builder( @@ -695,6 +797,8 @@ SourceMapDevToolPlugin: typeof SourceMapDevToolPlugin, HotModuleReplacementPlugin: typeof HotModuleReplacementPlugin, ContextReplacementPlugin: typeof ContextReplacementPlugin, + ProgressPlugin: typeof ProgressPlugin, + ProvidePlugin: typeof ProvidePlugin, ... }; }