/** * Size budgets, measured in a fresh process (see scripts/sizes.ts for why). * A regression fails the test and names the component that grew, rather than * only moving a total. Each component's budget is its measured size + ~15%, * set in the commit that lands the component. */ import { describe, expect, test } from "bun:test"; const BUDGETS: Record = { // the floor: an empty component through the consumer compiler, pebble bundled in (measured 4020) floor: 4620, // components land here: name: measured + ~15% // : the debounced, aborting fetch, the ARIA combobox wiring and keys, the sheet (measured 6627, Δ floor 2607) combobox: 7600, // : the click that swaps the poster link for the nocookie iframe, the sheet (measured 5049, Δ floor 1029) "lite-youtube": 5800, // : the observer, the fragment fetch and append, the live region, the sheet (measured 5728, Δ floor 1708) more: 6600, // tablet: pebble + the engine (pure-value model, own history), measured 7971 (Δ floor 3951); // + dialects and the decorated backdrop (keyed For, Show, switchMap, the sheet), measured 10060 (Δ floor 6040) tablet: 11600, // : table reading, the lifted chart reducer, keyed lanes, keys, the sheet (measured 11054, Δ floor 7034; // over the epic's ~6 kB target for a chart: trimming is pebble/library#2's to track); // 0.2.0, + the table view's sheet, row marks, keyed lanes and segments, motion: measured 11762 (Δ floor 7742); // + the fixed table layout and the target-width label cap: measured 11864 (Δ floor 7844); // + the measured table fit (whole words, hyphenated labels, fixed) and the @property sheet: measured 12173 (Δ floor 8153); // the fit replaced by a scroll region the table moves into, longer registered names: measured 12273 (Δ floor 8253) timeline: 14100, // : the pure tree model and reducer, recursive keyed runs, the menu, the template-cloned editor, the form seams, the sheet (measured 11391, Δ floor 7371) sequence: 13100, // : the toast stack, reducers + per-card lifetime streams (measured 8513) toaster: 9800, // : the optimistic press over the server's forms, the fetch, reconcile/rollback, the sheet (measured 6023, Δ floor 2003) vote: 6900, }; const proc = Bun.spawnSync(["bun", "run", "scripts/sizes.ts", "--json"], { cwd: `${import.meta.dir}/..` }); const report = JSON.parse(proc.stdout.toString().trim().split("\n").pop() ?? "{}"); describe("bundle size budgets (gzipped, release pipeline)", () => { test("the report was produced", () => { expect(proc.exitCode).toBe(0); expect(report.floor?.gz).toBeGreaterThan(0); }); for (const [name, budget] of Object.entries(BUDGETS)) { test(`${name} < ${budget} B gz`, () => { const row = name === "floor" ? report.floor : report.packages?.[name]; expect(row, `no measurement for ${name}`).toBeDefined(); const delta = row.delta === undefined ? "" : ` (Δ floor ${row.delta})`; console.log(`${name}: ${row.gz} B gz, ${row.br} B br${delta}`); expect(row.gz).toBeLessThan(budget); }); } });