3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 22:55:44 +01:00

Publish the bundle size in the README and fail the gate when it drifts a tenth

This commit is contained in:
2026-11-15 13:37:58 +01:00
committed by Lillem4n
parent 0a6522aa62
commit 6b7a8e691b
14 changed files with 698 additions and 36 deletions
+12
View File
@@ -0,0 +1,12 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { drift, minifiedGzippedBytes, packedBytes } from "./figures.mjs";
const root = resolve(import.meta.dirname, "..");
const measured = { minified: await minifiedGzippedBytes(root, "./dist/index.js"), ...packedBytes(root) };
console.log(`${(measured.minified / 1000).toFixed(1)} kB minified and gzipped; ${(measured.tarball / 1000).toFixed(1)} kB tarball, ${(measured.unpacked / 1000).toFixed(1)} kB unpacked`);
if (process.argv.includes("--check")) {
const problems = drift(readFileSync(resolve(root, "README.md"), "utf8"), measured);
for (const problem of problems) console.error(problem);
process.exit(problems.length === 0 ? 0 : 1);
}