From 409caddd883af63c07a5546ce4ce973b93e5520b Mon Sep 17 00:00:00 2001 From: rahim Date: Wed, 18 Mar 2026 22:32:37 -0700 Subject: [PATCH] refactor(ci): collapse unchanged packages in bundle size report (#1016) --- .github/scripts/bundle-size-report.js | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/scripts/bundle-size-report.js b/.github/scripts/bundle-size-report.js index b2dfbc86..098dda07 100644 --- a/.github/scripts/bundle-size-report.js +++ b/.github/scripts/bundle-size-report.js @@ -221,8 +221,6 @@ function generateComparisonReport(current, base) { const entries = groups.get(pkg) ?? []; const baseEntries = baseGroups.get(pkg) ?? []; const pkgIcon = pkgIcons[pkg] ?? '📦'; - lines.push(`## ${pkgIcon} @videojs/${pkg}`); - lines.push(''); // Entries with meaningful size changes (>300 B threshold). // For UI components, gate on standalone size to filter out phantom diffs @@ -238,10 +236,20 @@ function generateComparisonReport(current, base) { // Entries that existed in base but are missing in PR (removed) const removed = baseEntries.filter((e) => currentMap[e.name] === undefined); - if (changed.length === 0 && removed.length === 0) { - lines.push('(no changes)'); + const hasChanges = changed.length > 0 || removed.length > 0; + + // Category breakdowns for packages with categories (html, react) + const hasCategories = entries.some((e) => e.category); + const breakdownLines = hasCategories + ? generateCategoryBreakdowns(entries, pkg) + : entries.length > 1 + ? generateFlatBreakdown(entries, pkg) + : []; + + if (hasChanges) { + lines.push(`## ${pkgIcon} @videojs/${pkg}`); lines.push(''); - } else { + lines.push('| Path | Base | PR | Diff | % | |'); lines.push('|---|--:|--:|--:|--:|:-:|'); @@ -264,15 +272,14 @@ function generateComparisonReport(current, base) { } lines.push(''); - } - - // Category breakdowns for packages with categories (html, react) - const hasCategories = entries.some((e) => e.category); - if (hasCategories) { - lines.push(...generateCategoryBreakdowns(entries, pkg)); - } else if (entries.length > 1) { - // Flat breakdown for other packages with multiple entries - lines.push(...generateFlatBreakdown(entries, pkg)); + lines.push(...breakdownLines); + } else { + lines.push('
'); + lines.push(`${pkgIcon} @videojs/${pkg} — no changes`); + lines.push(''); + lines.push(...breakdownLines); + lines.push('
'); + lines.push(''); } }