diff --git a/scripts/size-report.js b/scripts/size-report.js index b6d2a0d6ae..9c6ce83b8e 100644 --- a/scripts/size-report.js +++ b/scripts/size-report.js @@ -175,15 +175,9 @@ async function buildBundleReport() { * @returns {string} */ function renderReport(report) { - const parts = ['## Bundle Size Report\n'] - - parts.push(renderSummary(report)) + const parts = [renderCompactHeader(report)] if (report.categories.length > 0) { - const glance = renderCategoryGlance(report) - if (glance) { - parts.push('\n' + glance) - } parts.push('\n' + renderCategoryDetails(report)) } @@ -195,6 +189,24 @@ function renderReport(report) { ) } +/** + * Render compact single-line header with key metrics + * @param {BundleReport} report + * @returns {string} + */ +function renderCompactHeader(report) { + const { overall, hasBaseline } = report + + const gzipSize = prettyBytes(overall.metrics.current.gzip) + let header = `## 📦 Bundle: ${gzipSize} gzip` + + if (hasBaseline) { + header += ` ${formatDiffIndicator(overall.metrics.diff.gzip)}` + } + + return header +} + /** * Render overall summary bullets * @param {BundleReport} report @@ -310,7 +322,16 @@ function renderCategoryGlance(report) { * @returns {string} */ function renderCategoryDetails(report) { - const lines = ['
', 'Per-category breakdown', ''] + const lines = ['
', 'Details', ''] + + lines.push(renderSummary(report)) + lines.push('') + + const glance = renderCategoryGlance(report) + if (glance) { + lines.push(glance) + lines.push('') + } for (const category of report.categories) { lines.push(renderCategoryBlock(category, report.hasBaseline))