time-analytics-webpack-plugin
Version:
analytize the time of loaders and plugins
110 lines (109 loc) • 3.4 kB
TypeScript
import type { Compiler, Configuration } from 'webpack';
import './sideEffects/hackWeakMap';
export declare class WebpackPlugin {
/**
* Apply the plugin
*/
apply(compiler: Compiler): void;
}
export type WebpackPluginLikeFunction = (this: Compiler, compiler: Compiler) => void;
interface TimeAnalyticsPluginOptions {
/**
* If fase, do nothing
*
* If true, output all loader and plugin infos.
*
* If object, loader and plugin could be turn off.
*
* Control loader and plugin with fine grained in `loader` and `plugin` options (not this option)
*
* @default true
*/
enable?: boolean | {
/**
* @default true
*/
loader: boolean;
/**
* @default true
*/
plugin: boolean;
};
/**
* If provided, write the result to a file.
*
* Otherwise the stdout stream.
*/
outputFile?: string;
/**
* Display the time as warning color if time is more than this limit.
*
* The unit is ms.
*
* @default 3000
*/
warnTimeLimit?: number;
/**
* Display the time as danger color if time is more than this limit.
*
* The unit is ms.
*
* @default 8000
*/
dangerTimeLimit?: number;
loader?: {
/**
* If true, output the absolute path of the loader.
*
* By default, the plugin displays loader time by a assumed loader name
*
* Like `babel-loader takes xxx ms.`
*
* The assumption is the loader's name is the first name after the last `node_modules` in the path.
*
* However, sometimes, it's not correct, like the loader's package is `@foo/loader1` then the assumed name is "@foo",
* or some framework like `next` will move the loader to some strange place.
*
* @default false
*/
groupedByAbsolutePath?: boolean;
/**
* If true, display the most time consumed resource's info
*
* @default 0
* @NotImplementYet
*/
topResources?: number;
/**
* The loaders that should not be analytized.
*
* Use the node package's name.
*/
exclude?: string[];
};
plugin?: {
/**
* The plugins that should not be analytized.
*
* The name is the plugin class itself, not the package's name.
*/
exclude?: string[];
};
}
interface WebpackConfigFactory {
(...args: any[]): Configuration;
}
export declare class TimeAnalyticsPlugin implements WebpackPlugin {
option: TimeAnalyticsPluginOptions | undefined;
apply(compiler: Compiler): void;
constructor(option: TimeAnalyticsPluginOptions | undefined);
static wrap(webpackConfigOrFactory: Configuration, options?: TimeAnalyticsPluginOptions): Configuration;
static wrap(webpackConfigOrFactory: WebpackConfigFactory, options?: TimeAnalyticsPluginOptions): WebpackConfigFactory;
get isLoaderEnabled(): boolean;
get isPluginEnabled(): boolean;
}
/**
* Fancy hack to judge whether an object is a Webpack plugin or function.
*/
export declare function isWebpackPlugin(p: any): p is WebpackPlugin;
export {};