diff --git a/apps/dashboard/src/App.tsx b/apps/dashboard/src/App.tsx index 7a2d754..2d9b486 100644 --- a/apps/dashboard/src/App.tsx +++ b/apps/dashboard/src/App.tsx @@ -1,5 +1,5 @@ import { useState } from 'react' -import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts' +import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, Cell } from 'recharts' import { BarChart3, Clock, Package, FileText } from 'lucide-react' import './App.css' import rolldownStats from '../../../rolldown-version-stats.json' @@ -15,10 +15,31 @@ const buildTimeData = rolldownStats.map(stat => ({ value: stat.buildTime })) -const bundleSizeData = rolldownStats.map(stat => ({ - name: `v${stat.version}`, - value: stat.totalSize // Use actual bytes instead of KB -})) +// Calculate bundle size differences between consecutive versions +const bundleSizeDiffData = rolldownStats.map((stat, index) => { + if (index === 0) { + // For the first version, show 0 difference or could show absolute value + return { + name: `v${stat.version}`, + value: 0, + previousSize: null, + currentSize: stat.totalSize, + isBaseline: true + } + } + + const prevSize = rolldownStats[index - 1].totalSize + const currentSize = stat.totalSize + const diff = currentSize - prevSize + + return { + name: `v${stat.version}`, + value: diff, + previousSize: prevSize, + currentSize: currentSize, + isBaseline: false + } +}) // Calculate file type breakdown from all versions const fileTypeStats = rolldownStats.reduce((acc, stat) => { @@ -42,17 +63,25 @@ const fileTypeData = Object.entries(fileTypeStats).map(([type, size]) => ({ function App() { const [selectedMetric, setSelectedMetric] = useState('buildTime') - // Custom tooltip formatter for bundle size - const customTooltipFormatter = (value: any, name: string) => { - if (selectedMetric === 'bundleSize') { - return [formatNumberWithCommas(value), name] + // Custom tooltip formatter for bundle size differences + const bundleSizeDiffTooltipFormatter = (value: any, name: string, props: any) => { + const data = props.payload + if (!data) return [value, name] + + if (data.isBaseline) { + return [`${formatNumberWithCommas(data.currentSize)} bytes (baseline)`, 'Bundle Size'] } - return [value, name] + + const sign = value >= 0 ? '+' : '' + const changeText = `${sign}${formatNumberWithCommas(value)} bytes` + const fromTo = `(${formatNumberWithCommas(data.previousSize)} → ${formatNumberWithCommas(data.currentSize)})` + + return [`${changeText} ${fromTo}`, 'Size Change'] } const metrics = [ { id: 'buildTime', name: 'Build Time', icon: Clock, data: buildTimeData, color: '#8884d8' }, - { id: 'bundleSize', name: 'Bundle Size', icon: Package, data: bundleSizeData, color: '#82ca9d' }, + { id: 'bundleSize', name: 'Bundle Size', icon: Package, data: bundleSizeDiffData, color: '#82ca9d' }, { id: 'fileTypes', name: 'File Types', icon: FileText, data: fileTypeData, color: '#ffc658' }, ] @@ -102,17 +131,33 @@ function App() { + ) : selectedMetric === 'bundleSize' ? ( + + + + + + + + {currentMetric.data.map((entry: any, index: number) => ( + = 0 ? '#ef4444' : '#22c55e')} + /> + ))} + + ) : ( - + )} @@ -127,7 +172,7 @@ function App() {

Latest Bundle Size

-

{formatNumberWithCommas(bundleSizeData[bundleSizeData.length - 1]?.value || 0)} bytes

+

{formatNumberWithCommas(rolldownStats[rolldownStats.length - 1]?.totalSize || 0)} bytes

v{rolldownStats[rolldownStats.length - 1]?.version}