refactor: hide npm pack budget helpers

This commit is contained in:
Peter Steinberger
2026-05-02 07:38:08 +01:00
parent 960fabdaef
commit 8080c9cf03
2 changed files with 3 additions and 13 deletions

View File

@@ -3,16 +3,6 @@ export type NpmPackBudgetResult = {
unpackedSize?: number;
};
export declare const NPM_PACK_UNPACKED_SIZE_BUDGET_BYTES: number;
export declare function formatMiB(bytes: number): string;
export declare function formatPackUnpackedSizeBudgetError(params: {
budgetBytes?: number;
label: string;
unpackedSize: number;
}): string;
export declare function collectPackUnpackedSizeErrors(
results: Iterable<NpmPackBudgetResult>,
options?: {

View File

@@ -3,9 +3,9 @@
// dependencies, including crypto wasm, so packaged installs do not miss Docker
// and gateway runtime dependencies. Keep the budget below the 2026.3.12 bloat
// level while allowing that mirrored runtime surface.
export const NPM_PACK_UNPACKED_SIZE_BUDGET_BYTES = 202 * 1024 * 1024;
const NPM_PACK_UNPACKED_SIZE_BUDGET_BYTES = 202 * 1024 * 1024;
export function formatMiB(bytes) {
function formatMiB(bytes) {
return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
}
@@ -13,7 +13,7 @@ function resolvePackResultLabel(entry, index) {
return entry.filename?.trim() || `pack result #${index + 1}`;
}
export function formatPackUnpackedSizeBudgetError(params) {
function formatPackUnpackedSizeBudgetError(params) {
const budgetBytes = params.budgetBytes ?? NPM_PACK_UNPACKED_SIZE_BUDGET_BYTES;
return [
`${params.label} unpackedSize ${params.unpackedSize} bytes (${formatMiB(params.unpackedSize)}) exceeds budget ${budgetBytes} bytes (${formatMiB(budgetBytes)}).`,