@@ -4,6 +4,11 @@ import { BarChart3, Clock, Package, FileText } from 'lucide-react'
44import './App.css'
55import rolldownStats from '../../../rolldown-version-stats.json'
66
7+ // Utility function to format numbers with commas
8+ const formatNumberWithCommas = ( num : number ) : string => {
9+ return num . toLocaleString ( )
10+ }
11+
712// Transform rolldown stats data for charts
813const buildTimeData = rolldownStats . map ( stat => ( {
914 name : `v${ stat . version } ` ,
@@ -12,7 +17,7 @@ const buildTimeData = rolldownStats.map(stat => ({
1217
1318const bundleSizeData = rolldownStats . map ( stat => ( {
1419 name : `v${ stat . version } ` ,
15- value : Math . round ( stat . totalSize / 1024 ) // Convert to KB
20+ value : stat . totalSize // Use actual bytes instead of KB
1621} ) )
1722
1823// Calculate file type breakdown from all versions
@@ -37,6 +42,14 @@ const fileTypeData = Object.entries(fileTypeStats).map(([type, size]) => ({
3742function App ( ) {
3843 const [ selectedMetric , setSelectedMetric ] = useState ( 'buildTime' )
3944
45+ // Custom tooltip formatter for bundle size
46+ const customTooltipFormatter = ( value : any , name : string ) => {
47+ if ( selectedMetric === 'bundleSize' ) {
48+ return [ formatNumberWithCommas ( value ) , name ]
49+ }
50+ return [ value , name ]
51+ }
52+
4053 const metrics = [
4154 { id : 'buildTime' , name : 'Build Time' , icon : Clock , data : buildTimeData , color : '#8884d8' } ,
4255 { id : 'bundleSize' , name : 'Bundle Size' , icon : Package , data : bundleSizeData , color : '#82ca9d' } ,
@@ -94,12 +107,12 @@ function App() {
94107 < CartesianGrid strokeDasharray = "3 3" />
95108 < XAxis dataKey = "name" />
96109 < YAxis />
97- < Tooltip />
110+ < Tooltip formatter = { selectedMetric === 'bundleSize' ? customTooltipFormatter : undefined } />
98111 < Legend />
99112 < Bar
100113 dataKey = "value"
101114 fill = { currentMetric . color }
102- name = { selectedMetric === 'buildTime' ? 'Build Time (ms)' : 'Bundle Size (KB )' }
115+ name = { selectedMetric === 'buildTime' ? 'Build Time (ms)' : 'Bundle Size (bytes )' }
103116 />
104117 </ BarChart >
105118 ) }
@@ -114,7 +127,7 @@ function App() {
114127 </ div >
115128 < div className = "stat-card" >
116129 < h3 > Latest Bundle Size</ h3 >
117- < p className = "stat-value" > { bundleSizeData [ bundleSizeData . length - 1 ] ?. value } KB </ p >
130+ < p className = "stat-value" > { formatNumberWithCommas ( bundleSizeData [ bundleSizeData . length - 1 ] ?. value || 0 ) } bytes </ p >
118131 < span className = "stat-change positive" > v{ rolldownStats [ rolldownStats . length - 1 ] ?. version } </ span >
119132 </ div >
120133 < div className = "stat-card" >
0 commit comments