UNPKG

time-analytics-webpack-plugin

Version:
138 lines (137 loc) 3.54 kB
export declare enum AnalyzeInfoKind { loader = 0, plugin = 1, webpackMeta = 2 } export declare enum LoaderType { pitch = 0, normal = 1 } export declare enum LoaderEventType { start = 0, end = 1 } export interface LoaderEventInfo { /** * Id for each pitch/normal loader function call . * * pitch and normal loader function for the same resource also have different call Id. */ callId: string; kind: AnalyzeInfoKind.loader; loaderType: LoaderType; /** * the absolute path to the loader */ loaderPath: string; time: number; /** * source file that the loader is handling */ resourcePath: string; /** * what does this event stands for, start or end. */ eventType: LoaderEventType; /** * Whether this loader is async loader or sync loader. * * async loader means this loader calls `this.async()`, only `end` event is accurate, `start` event will always set this to `false`. */ isAsync: boolean; } export declare enum TapType { normal = 0, async = 1, promise = 2 } export declare enum PluginEventType { start = 0, end = 1 } export interface PluginEventInfo { kind: AnalyzeInfoKind.plugin; /** * The name of the plugin */ pluginName: string; /** * The first parameter of tap function, is this useful? * * For now, we are accessing the name through `pluginInstance.constructor.name` */ tapId?: never; time: number; tapType: TapType; /** * ID for each tap call. */ tapCallId: string; /** * what does this event stands for, start or end. */ eventType: PluginEventType; } /** * The exact one hook of webpack * * Name format is `${hooks container name}_${hook name}` */ export declare enum WebpackMetaEventType { Compiler_compile = 0, Compiler_done = 1 } /** * The aim is to record timestap of some event which only runs for once */ export interface WebpackMetaEventInfo { kind: AnalyzeInfoKind.webpackMeta; time: number; hookType: WebpackMetaEventType; } export interface OutputOption { /** * If there is a path, will output the content to the file. * * If file is not exist, will create it, but the folder must be existed. * * If file is exist, overwrite the content. */ filePath?: string; warnTimeLimit: number; dangerTimeLimit: number; groupLoaderByPath: boolean; ignoredLoaders: string[]; } declare class WebpackTimeAnalyzer { private _isInitilized; initilize(): void; clear(): void; private loaderData; collectLoaderInfo(loaderInfo: LoaderEventInfo): void; private pluginData; collectPluginInfo(pluginInfo: PluginEventInfo): void; private metaData; collectWebpackInfo(metaInfo: WebpackMetaEventInfo): void; output(option: OutputOption): void; } export interface MetaAnalyticsResult { totalTime: number; } export interface PluginAnalyticsResult { pluginsInfo: { name: string; time: number; }[]; } export interface LoaderAnalyticsResult { loadersInfo: { path: string; /** * `0` means the loader is ignored. @see {@link AnalyticsLoaderOptions.ignoredLoaders} */ time: number; }[]; } export declare const analyzer: WebpackTimeAnalyzer; export {};