library
Prebuilt pebble components: drop-in custom elements, no compiler needed
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runAucun
0Étoiles
0Forks
2Issues
| 1 | /** |
| 2 | * Size budgets, measured in a fresh process (see scripts/sizes.ts for why). |
| 3 | * A regression fails the test and names the component that grew, rather than |
| 4 | * only moving a total. Each component's budget is its measured size + ~15%, |
| 5 | * set in the commit that lands the component. |
| 6 | */ |
| 7 | import { describe, expect, test } from "bun:test"; |
| 8 | |
| 9 | const BUDGETS: Record<string, number> = { |
| 10 | // the floor: an empty component through the consumer compiler, pebble bundled in (measured 4020) |
| 11 | floor: 4620, |
| 12 | // components land here: name: measured + ~15% |
| 13 | // <pebble-combobox>: the debounced, aborting fetch, the ARIA combobox wiring and keys, the sheet (measured 6627, Δ floor 2607) |
| 14 | combobox: 7600, |
| 15 | // <pebble-lite-youtube>: the click that swaps the poster link for the nocookie iframe, the sheet (measured 5049, Δ floor 1029) |
| 16 | "lite-youtube": 5800, |
| 17 | // <pebble-more>: the observer, the fragment fetch and append, the live region, the sheet (measured 5728, Δ floor 1708) |
| 18 | more: 6600, |
| 19 | // tablet: pebble + the engine (pure-value model, own history), measured 7971 (Δ floor 3951); |
| 20 | // + dialects and the decorated backdrop (keyed For, Show, switchMap, the sheet), measured 10060 (Δ floor 6040) |
| 21 | tablet: 11600, |
| 22 | // <pebble-timeline>: table reading, the lifted chart reducer, keyed lanes, keys, the sheet (measured 11054, Δ floor 7034; |
| 23 | // over the epic's ~6 kB target for a chart: trimming is pebble/library#2's to track); |
| 24 | // 0.2.0, + the table view's sheet, row marks, keyed lanes and segments, motion: measured 11762 (Δ floor 7742); |
| 25 | // + the fixed table layout and the target-width label cap: measured 11864 (Δ floor 7844); |
| 26 | // + the measured table fit (whole words, hyphenated labels, fixed) and the @property sheet: measured 12173 (Δ floor 8153); |
| 27 | // the fit replaced by a scroll region the table moves into, longer registered names: measured 12273 (Δ floor 8253) |
| 28 | timeline: 14100, |
| 29 | // <pebble-sequence>: the pure tree model and reducer, recursive keyed runs, the menu, the template-cloned editor, the form seams, the sheet (measured 11391, Δ floor 7371) |
| 30 | sequence: 13100, |
| 31 | // <pebble-toaster>: the toast stack, reducers + per-card lifetime streams (measured 8513) |
| 32 | toaster: 9800, |
| 33 | // <pebble-vote>: the optimistic press over the server's forms, the fetch, reconcile/rollback, the sheet (measured 6023, Δ floor 2003) |
| 34 | vote: 6900, |
| 35 | }; |
| 36 | |
| 37 | const proc = Bun.spawnSync(["bun", "run", "scripts/sizes.ts", "--json"], { cwd: `${import.meta.dir}/..` }); |
| 38 | const report = JSON.parse(proc.stdout.toString().trim().split("\n").pop() ?? "{}"); |
| 39 | |
| 40 | describe("bundle size budgets (gzipped, release pipeline)", () => { |
| 41 | test("the report was produced", () => { |
| 42 | expect(proc.exitCode).toBe(0); |
| 43 | expect(report.floor?.gz).toBeGreaterThan(0); |
| 44 | }); |
| 45 | |
| 46 | for (const [name, budget] of Object.entries(BUDGETS)) { |
| 47 | test(`${name} < ${budget} B gz`, () => { |
| 48 | const row = name === "floor" ? report.floor : report.packages?.[name]; |
| 49 | expect(row, `no measurement for ${name}`).toBeDefined(); |
| 50 | const delta = row.delta === undefined ? "" : ` (Δ floor ${row.delta})`; |
| 51 | console.log(`${name}: ${row.gz} B gz, ${row.br} B br${delta}`); |
| 52 | expect(row.gz).toBeLessThan(budget); |
| 53 | }); |
| 54 | } |
| 55 | }); |