Skip to content

Commit

Permalink
Fixing bundle report size for bundle that doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Sep 17, 2021
1 parent 852da9d commit 53e78d1
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions script/bundle-size-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,41 @@ const posNeg = v => (v > 0 ? '+ ' : v < 0 ? '- ' : '')

// Build the rows
for (const name of Object.keys(currentBundles)) {
const current = currentBundles[name]
const latest = latestBundles[name]
const {
stats: {
selectors: {
total: current_selectors_total
},
gzipSize: current_gzip_size,
size: current_size
}
} = currentBundles[name] || { stats: { selectors: { total: 0 }, gzipSize: 0, size: 0 } }

const {
stats: {
selectors: {
total: latest_selectors_total
},
gzipSize: latest_gzip_size,
size: latest_size
}
} = latestBundles[name] || { stats: { selectors: { total: 0 }, gzipSize: 0, size: 0 } }

const delta = [
current.stats.selectors.total - latest.stats.selectors.total,
current.stats.gzipSize - latest.stats.gzipSize,
current.stats.size - latest.stats.size
current_selectors_total - latest_selectors_total,
current_gzip_size - latest_gzip_size,
current_size - latest_size
].reduce((a, b) => a + b, 0)

if (delta !== 0) {
data.push([
current.name,
current.stats.selectors.total,
current.stats.selectors.total - latest.stats.selectors.total,
current.stats.gzipSize,
current.stats.gzipSize - latest.stats.gzipSize,
current.stats.size,
current.stats.size - latest.stats.size
name,
current_selectors_total,
current_selectors_total - latest_selectors_total,
current_gzip_size,
current_gzip_size - latest_gzip_size,
current_size,
current_size - latest_size
])
}
}
Expand Down

0 comments on commit 53e78d1

Please sign in to comment.