Files
warkanum 538ec38632
CI / test-and-build (push) Successful in 30s
Add collection and sorting utilities with Gitea release workflows
Replace retrocycle eval calls with property traversal and regression coverage. Add bundle budgets, eval guards, package publishing, and contributor documentation.
2026-09-23 19:22:12 +02:00

22 lines
1001 B
JavaScript

import { readFile, readdir } from 'node:fs/promises';
import { gzipSync } from 'node:zlib';
const dist = new URL('../dist/', import.meta.url);
const budgets = JSON.parse(await readFile(new URL('./bundle-budgets.json', import.meta.url), 'utf8'));
const files = (await readdir(dist)).filter(file => file.endsWith('.js'));
let failed = false;
for (const file of new Set([...files, ...Object.keys(budgets)])) {
const budget = budgets[file];
if (!budget || !files.includes(file)) {
console.error(`${file}: missing ${budget ? 'build output' : 'bundle budget'}`);
failed = true;
continue;
}
const source = await readFile(new URL(file, dist));
const bytes = source.byteLength;
const gzip = gzipSync(source).byteLength;
console.log(`${file}: ${bytes}/${budget.bytes} bytes; gzip ${gzip}/${budget.gzip} bytes`);
if (bytes > budget.bytes || gzip > budget.gzip) failed = true;
}
if (failed) throw new Error('Bundle budget check failed. Review size changes before updating budgets.');