From e6c156da23ddd37497340a798507a1ecdae8bc8a Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 2 Jun 2026 22:00:50 -0500 Subject: [PATCH] fix: drop gzip, report unpacked install size only --- .github/workflows/size-report.yml | 27 ++++++++++----------------- tasks/measure-size.ts | 12 +++--------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/size-report.yml b/.github/workflows/size-report.yml index 84ac49c..1d8ce71 100644 --- a/.github/workflows/size-report.yml +++ b/.github/workflows/size-report.yml @@ -67,21 +67,17 @@ jobs: const head = JSON.parse(fs.readFileSync('/tmp/head-sizes.json', 'utf8')); const base = JSON.parse(fs.readFileSync('/tmp/base-sizes.json', 'utf8')); - const total = (arr) => arr.reduce( - (acc, f) => ({ raw: acc.raw + f.raw, gzip: acc.gzip + f.gzip }), - { raw: 0, gzip: 0 } - ); + const total = (arr) => arr.reduce((acc, f) => acc + f.size, 0); const headTotal = total(head); const baseTotal = total(base); - const deltaRaw = headTotal.raw - baseTotal.raw; - const deltaGzip = headTotal.gzip - baseTotal.gzip; + const delta = headTotal - baseTotal; const fmt = (n) => `${(n / 1024).toFixed(1)} KB`; const fmtDelta = (n) => - n === 0 ? '±0 KB' : `${n > 0 ? '+' : ''}${(n / 1024).toFixed(1)} KB`; + `${n > 0 ? '+' : ''}${(n / 1024).toFixed(1)} KB`; - if (deltaGzip === 0 && deltaRaw === 0) return; + if (delta === 0) return; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, @@ -93,21 +89,18 @@ jobs: // Skip if the head sizes haven't changed since the last push if (existing) { - const match = existing.body.match(//); - if (match) { - const prev = JSON.parse(match[1]); - if (prev.raw === headTotal.raw && prev.gzip === headTotal.gzip) return; - } + const match = existing.body.match(//); + if (match && Number(match[1]) === headTotal) return; } - const takeaway = deltaGzip < 0 ? 'Size Reduced' : 'Size Increased'; + const takeaway = delta < 0 ? 'Size Reduced' : 'Size Increased'; const body = [ '', - ``, - `**${takeaway}** — ${fmtDelta(deltaGzip)} gz, ${fmtDelta(deltaRaw)} raw`, + ``, + `**${takeaway}** — ${fmtDelta(delta)}`, '', - `${fmt(headTotal.gzip)} gz (${fmt(headTotal.raw)} raw)`, + `${fmt(headTotal)} unpacked`, ].join('\n'); if (existing) { diff --git a/tasks/measure-size.ts b/tasks/measure-size.ts index 714b160..bb55a2b 100644 --- a/tasks/measure-size.ts +++ b/tasks/measure-size.ts @@ -1,17 +1,11 @@ -import { gzipSync } from "node:zlib"; - const dir = "build/npm/esm"; -const results: Array<{ file: string; raw: number; gzip: number }> = []; +const results: Array<{ file: string; size: number }> = []; for await (const entry of Deno.readDir(dir)) { if (!entry.isFile) continue; let path = `${dir}/${entry.name}`; - let data = await Deno.readFile(path); - results.push({ - file: entry.name, - raw: data.byteLength, - gzip: gzipSync(data).byteLength, - }); + let { size } = await Deno.stat(path); + results.push({ file: entry.name, size }); } results.sort((a, b) => a.file.localeCompare(b.file)); -- 2.51.2