@@ -129,34 +129,34 @@ export async function generateMarkdownReport(
129129) {
130130 const grouped : Record < string , { bundler : string ; size : number } [ ] > = { } ;
131131 for ( const r of results ) {
132- if ( ! grouped [ r . example ] ) grouped [ r . example ] = [ ] ;
133- grouped [ r . example ] ?. push ( { bundler : r . bundler , size : r . size } ) ;
132+ const arr = grouped [ r . example ] ?? [ ] ;
133+ arr . push ( { bundler : r . bundler , size : r . size } ) ;
134+ grouped [ r . example ] = arr ;
134135 }
135136
136137 let report = '# Bundler Efficiency Report\n\n' ;
137138
138139 for ( const example of Object . keys ( grouped ) ) {
139- if ( grouped [ example ] ) {
140- // Read snippet code
141- let snippet = '' ;
142- try {
143- const snippetPath = path . join (
144- 'examples' ,
145- example + ( example . endsWith ( '.ts' ) ? '' : '.ts' ) ,
146- ) ;
147- snippet = await fs . readFile ( snippetPath , 'utf8' ) ;
148- } catch ( e ) {
149- snippet = '_Could not read example source._' ;
150- }
151- report += `## ${ example } \n\n` ;
152- report += `\`\`\`typescript\n${ snippet . trim ( ) } \n\`\`\`\n\n` ;
153- report += '| Bundler | Bundle Size (bytes) |\n' ;
154- report += '|---------|---------------------|\n' ;
155- for ( const row of grouped [ example ] ) {
156- report += `| \`${ row . bundler } \` | ${ row . size } |\n` ;
157- }
158- report += '\n' ;
140+ const rows = grouped [ example ] ?? [ ] ;
141+ // Read snippet code
142+ let snippet = '' ;
143+ try {
144+ const snippetPath = path . join (
145+ 'examples' ,
146+ example + ( example . endsWith ( '.ts' ) ? '' : '.ts' ) ,
147+ ) ;
148+ snippet = await fs . readFile ( snippetPath , 'utf8' ) ;
149+ } catch ( e ) {
150+ snippet = '_Could not read example source._' ;
159151 }
152+ report += `## ${ example } \n\n` ;
153+ report += `\`\`\`typescript\n${ snippet . trim ( ) } \n\`\`\`\n\n` ;
154+ report += '| Bundler | Bundle Size (bytes) |\n' ;
155+ report += '|---------|---------------------|\n' ;
156+ for ( const row of rows ) {
157+ report += `| \`${ row . bundler } \` | ${ row . size } |\n` ;
158+ }
159+ report += '\n' ;
160160 }
161161
162162 // General table
0 commit comments