@stacksjs/stx
Version:
A performant UI Framework. Powered by Bun.
66 lines • 1.75 kB
TypeScript
import path from 'node:path';
/**
* Collect bundle statistics from a build directory
*/
export declare function collectBundleStats(buildDir: string, options?: CollectorOptions): Promise<BundleStats>;
/**
* Format bytes to human readable string
*/
export declare function formatBytes(bytes: number): string;
/**
* Parse size string to bytes
*/
export declare function parseSize(size: string): number;
/**
* Calculate percentage
*/
export declare function percentage(part: number, total: number): string;
// ============================================================================
// Types
// ============================================================================
export declare interface ModuleInfo {
id: string
path: string
size: number
gzipSize: number
parsedSize: number
extension: string
type: ModuleType
imports: string[]
importedBy: string[]
hash: string
}
export declare interface ChunkInfo {
name: string
files: string[]
modules: ModuleInfo[]
size: number
gzipSize: number
isEntry: boolean
isVendor: boolean
}
export declare interface DuplicateModule {
path: string
count: number
wastedBytes: number
locations: string[]
}
export declare interface BundleStats {
timestamp: number
buildDir: string
chunks: ChunkInfo[]
totalSize: number
totalGzipSize: number
moduleCount: number
duplicates: DuplicateModule[]
byType: Record<ModuleType, { count: number; size: number; gzipSize: number }>
largestModules: ModuleInfo[]
warnings: string[]
}
export declare interface CollectorOptions {
includeSourceMaps?: boolean
parseImports?: boolean
detectDuplicates?: boolean
topModulesCount?: number
}
export type ModuleType = 'js' | 'css' | 'html' | 'image' | 'font' | 'other'