import type binding from '@rspack/binding'; import type { JsOriginRecord } from '@rspack/binding'; import type { Compilation } from '../Compilation.js'; import type { StatsOptions } from '../config/index.js'; import type { StatsFactory, StatsFactoryContext } from './StatsFactory.js'; export type KnownStatsChunkGroup = { name?: string; chunks?: (string | number)[]; assets?: { name: string; size?: number; }[]; filteredAssets?: number; assetsSize?: number; auxiliaryAssets?: { name: string; size?: number; }[]; filteredAuxiliaryAssets?: number; auxiliaryAssetsSize?: number; children?: { preload?: StatsChunkGroup[]; prefetch?: StatsChunkGroup[]; }; childAssets?: { preload?: string[]; prefetch?: string[]; }; isOverSizeLimit?: boolean; }; export type KnownStatsChunk = { type: string; rendered: boolean; initial: boolean; entry: boolean; reason?: string; size: number; sizes?: Record; names?: string[]; idHints?: string[]; runtime?: string[]; files?: string[]; auxiliaryFiles?: string[]; hash?: string; childrenByOrder?: Record; id?: string | number; siblings?: (string | number)[]; parents?: (string | number)[]; children?: (string | number)[]; modules?: StatsModule[]; filteredModules?: number; origins?: StatsChunkOrigin[]; }; export type KnownAssetInfo = { immutable?: boolean; minimized?: boolean; fullhash?: string | string[]; chunkhash?: string | string[]; contenthash?: string | string[]; sourceFilename?: string; copied?: boolean; size?: number; development?: boolean; hotModuleReplacement?: boolean; javascriptModule?: boolean; related?: Record; }; export type AssetInfo = KnownAssetInfo & Record; export type StatsChunkGroup = KnownStatsChunkGroup & Record; export type KnownStatsAsset = { type: string; name: string; info: AssetInfo; size: number; emitted: boolean; cached: boolean; related?: StatsAsset[]; chunkNames?: (string | number)[]; chunkIdHints?: (string | number)[]; chunks?: (string | number | null | undefined)[]; auxiliaryChunkNames?: (string | number)[]; auxiliaryChunks?: (string | number | null | undefined)[]; auxiliaryChunkIdHints?: (string | number)[]; filteredRelated?: number; isOverSizeLimit?: boolean; }; export type StatsAsset = KnownStatsAsset & Record; export type StatsChunk = KnownStatsChunk & Record; export type KnownStatsModule = { type: string; moduleType: string; layer?: string; identifier?: string; name?: string; nameForCondition?: string; index?: number; index2?: number; preOrderIndex?: number; postOrderIndex?: number; size: number; sizes: Record; cacheable?: boolean; built: boolean; codeGenerated: boolean; buildTimeExecuted: boolean; cached: boolean; optional?: boolean; orphan?: boolean; id?: string | number | null; issuerId?: string | number | null; chunks?: (string | number)[]; assets?: string[]; dependent?: boolean; issuer?: string; issuerName?: string; issuerPath?: StatsModuleIssuer[]; failed?: boolean; errors?: number; warnings?: number; reasons?: StatsModuleReason[]; usedExports?: boolean | string[] | null; providedExports?: string[] | null; optimizationBailout?: string[] | null; depth?: number; modules?: StatsModule[]; filteredModules?: number; source?: string | Buffer; }; export type KnownStatsProfile = { total: number; resolving: number; building: number; }; export type StatsModule = KnownStatsModule & Record; export type KnownStatsModuleIssuer = { identifier?: string; name?: string; id?: string | number | null; }; export type StatsModuleIssuer = KnownStatsModuleIssuer & Record; export declare enum StatsErrorCode { /** * Warning generated when either builtin `SwcJsMinimizer` or `LightningcssMinimizer` fails to minify the code. */ ChunkMinificationError = "ChunkMinificationError", /** * Warning generated when either builtin `SwcJsMinimizer` or `LightningcssMinimizer` fails to minify the code. */ ChunkMinificationWarning = "ChunkMinificationWarning", /** * Error generated when a module is failed to be parsed */ ModuleParseError = "ModuleParseError", /** * Warning generated when a module is failed to be parsed */ ModuleParseWarning = "ModuleParseWarning", /** * Error generated when a module is failed to be built (i.e being built by a * loader) */ ModuleBuildError = "ModuleBuildError" } export type KnownStatsError = { message: string; code?: StatsErrorCode | string; chunkName?: string; chunkEntry?: boolean; chunkInitial?: boolean; /** * A custom filename associated with this error/warning. */ file?: string; /** * The identifier of the module related to this error/warning. * Usually an absolute path, may include inline loader requests. * @example * - `/path/to/project/src/index.js` * - `!builtin:react-refresh-loader!/path/to/project/src/index.css` */ moduleIdentifier?: string; /** * The readable name of the module related to this error/warning. * Usually a relative path, no inline loader requests. * @example * - `"./src/index.js"` * - `"./src/index.css"` */ moduleName?: string; loc?: string; chunkId?: string | number; moduleId?: string | number | null; moduleTrace?: StatsModuleTraceItem[]; details?: any; stack?: string; }; export type StatsError = KnownStatsError & Record; export type StatsModuleTraceItem = { originIdentifier?: string; originName?: string; moduleIdentifier?: string; moduleName?: string; originId?: string | number | null; moduleId?: string | number | null; dependencies?: StatsModuleTraceDependency[]; }; export type StatsModuleTraceDependency = KnownStatsModuleTraceDependency & Record; export type KnownStatsModuleTraceDependency = { loc: string; }; export type KnownStatsModuleReason = { moduleIdentifier?: string; module?: string; moduleName?: string; resolvedModuleIdentifier?: string; resolvedModule?: string; type?: string; active: boolean; explanation?: string; userRequest?: string; loc?: string; moduleId?: string | number | null; resolvedModuleId?: string | number | null; }; export type StatsModuleReason = KnownStatsModuleReason & Record; export type KnownStatsChunkOrigin = { module: string; moduleIdentifier: string; moduleName: string; loc: string; request: string; moduleId?: string | number | null; }; export type StatsChunkOrigin = KnownStatsChunkOrigin & Record; export type KnownStatsCompilation = { /** * webpack version. * this is a hack to be compatible with plugin which detect webpack's version */ version?: string; /** rspack version */ rspackVersion?: string; name?: string; hash?: string; time?: number; builtAt?: number; publicPath?: string; outputPath?: string; assets?: StatsAsset[]; assetsByChunkName?: Record; chunks?: StatsChunk[]; modules?: StatsModule[]; entrypoints?: Record; namedChunkGroups?: Record; errors?: StatsError[]; errorsCount?: number; warnings?: StatsError[]; warningsCount?: number; filteredModules?: number; children?: StatsCompilation[]; logging?: Record; }; export type StatsCompilation = KnownStatsCompilation & Record; export type StatsLogging = KnownStatsLogging & Record; export type KnownStatsLogging = { entries: StatsLoggingEntry[]; filteredEntries: number; debug: boolean; }; export type StatsLoggingEntry = KnownStatsLoggingEntry & Record; export type KnownStatsLoggingEntry = { type: string; message: string; trace?: string[] | undefined; children?: StatsLoggingEntry[] | undefined; args?: any[] | undefined; time?: number | undefined; }; type ExtractorsByOption = { [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void; }; export type PreprocessedAsset = binding.JsStatsAsset & { type: string; related: PreprocessedAsset[]; info: binding.JsStatsAssetInfo; }; export type SimpleExtractors = { compilation: ExtractorsByOption; asset$visible: ExtractorsByOption; asset: ExtractorsByOption; chunkGroup: ExtractorsByOption<{ name: string; chunkGroup: binding.JsStatsChunkGroup; }, StatsChunkGroup>; module: ExtractorsByOption; module$visible: ExtractorsByOption; moduleIssuer: ExtractorsByOption; moduleReason: ExtractorsByOption; chunk: ExtractorsByOption; chunkOrigin: ExtractorsByOption; error: ExtractorsByOption; warning: ExtractorsByOption; moduleTraceItem: ExtractorsByOption; moduleTraceDependency: ExtractorsByOption; }; export declare const iterateConfig: (config: Record>, options: StatsOptions, fn: (a1: string, a2: Function) => void) => void; type Child = { children?: ItemChildren; filteredChildren?: number; }; type ItemChildren = Child[]; export declare const collapse: (children: ItemChildren) => Child[]; export declare const spaceLimited: (itemsAndGroups: ItemChildren, max: number, filteredChildrenLineReserved?: boolean) => { children: any; filteredChildren: any; }; export declare const countWithChildren: (compilation: Compilation, getItems: (compilation: Compilation, key: string) => any[]) => number; export declare const sortByField: (field: string) => ((a1: Object, a2: Object) => number); export declare const assetGroup: (children: StatsAsset[]) => { size: number; }; export declare const moduleGroup: (children: { size: number; sizes: Record; }[]) => { size: number; sizes: Record; }; export declare const mergeToObject: (items: { [key: string]: any; name: string; }[]) => Object; export declare const errorsSpaceLimit: (errors: StatsError[], max: number) => { errors: StatsError[]; filtered: number; }; export declare const warningFromStatsWarning: (warning: binding.JsStatsError) => Error; export {};