export type BuildResult = { name: string; path: string; minifiedSize: number; gzippedSize: number; }; /** * Closed union of asset types monosize knows how to measure today. * Adding a member is purely additive — existing keys are unchanged * and consumers using `Partial>` see the * new key as valid. */ export type AssetType = 'js' | 'json' | 'css'; export type AssetSize = Pick; export type BundleSizeReportEntry = Pick & { packageName: string; /** * Per-asset-type breakdown. Keys are members of `AssetType`; only types * that produced output appear. Always populated by `measure` (possibly * `{}` when no allowlisted extension matched). May be absent on entries * returned from storage written before this change. */ assets?: Partial>; /** * The threshold resolved from the nearest `monosize.config` at `measure` * time and captured per entry, already parsed to its structured form. * Because `measure` runs per package, this reflects that package's own * config (or the inherited root config). `compare-reports` gates each entry * on its own value, falling back to the root/default threshold when absent * (no threshold configured anywhere, or a legacy report written before this * field existed). */ threshold?: ThresholdValue; }; export type BundleSizeReport = BundleSizeReportEntry[]; /** * Shape of one entry as it sits on disk in a per-package `monosize.json`, * before `collectLocalReport` adds `packageName`. */ export type StoredReportEntry = Omit; export type ThresholdValue = { size: number; type: 'size' | 'percent'; }; export type StorageAdapter = { getRemoteReport(branch: string): Promise<{ commitSHA: string; remoteReport: BundleSizeReport; }>; uploadReportToRemote(branch: string, commitSHA: string, localReport: BundleSizeReport): Promise; }; export type BundlerAdapter = { buildFixture: (options: { fixturePath: string; debug: boolean; quiet: boolean; }) => Promise<{ /** * Directory containing the bundler's output for this fixture. The CLI * walks this directory non-recursively, classifies files by extension * against the configured `assetTypes` allowlist, and reports per-type * sizes plus totals. */ outputDir: string; /** * Optional directory containing beautified-JS output for debugging * (debug mode only). A separate directory from `outputDir` so the * CLI's extension scan never reads it and there's no risk of the * debug build overwriting the production bundle. */ debugOutputDir?: string; }>; /** * Build fixtures in a batch operation. * When implemented, this can significantly reduce build time for bundlers that support multiple entry points. */ buildFixtures: (options: { fixtures: Array<{ fixturePath: string; name: string; }>; debug: boolean; quiet: boolean; }) => Promise>; /** A friendly name of the bundler used for logging. */ name: string; }; /** * @kind shared */ export type BundlerAdapterFactoryConfig> = (config: T) => T; /** * @kind shared */ export type BundleAdapterFactory> = (options: BundlerAdapterFactoryConfig) => BundlerAdapter; type ReportResolvers = { /** * Override package name resolution used within compare-reports and upload-report. * * By default we try to read package name from "package.json" or "project.json" files. * You can override this behavior by providing your own implementation. */ packageName?: (packageRoot: string) => Promise; /** * * Override package root resolution used within compare-reports and upload-report. * * By default we try to resolve package root by traversing up the directory tree until we find "package.json" or "project.json" files. * You can override this behavior by providing your own implementation. * * @param reportFilePath - absolute path to the report file (monosize.json) */ packageRoot?: (reportFilePath: string) => Promise; }; export type MonoSizeConfig = { repository: string; storage: StorageAdapter; bundler: BundlerAdapter; /** * Report Commands Configuration Overrides * Use this if you need to customize package name or package root resolution logic within bundle reports. */ reportResolvers?: ReportResolvers; /** * A threshold limit for checking if the bundle size is within the limit. * It should be a string with a number and unit. Format: `0.5 kB`, `1kB, `10%`. */ threshold?: string; /** * Asset types to measure. Each entry must be a member of `AssetType` * (`'js' | 'json' | 'css'`). Files of other types in the bundler output * directory are ignored. Default: `['js']` — opt in to `'css'` / `'json'` * by listing them explicitly. */ assetTypes?: AssetType[]; }; /** * Internal config shape returned by `readConfig` after defaults and * validation have been applied. Not exported from the public package * surface; downstream commands consume this directly so they don't * need to re-apply defaults. */ export type LoadedMonoSizeConfig = Omit & { assetTypes: AssetType[]; }; export {}; //# sourceMappingURL=types.d.mts.map