Skip to content

Commit

Permalink
Shows brotli size in report
Browse files Browse the repository at this point in the history
  • Loading branch information
WhitWaldo committed Mar 30, 2022
1 parent 7d6039e commit 7181f59
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/components/ModulesTreemap.jsx
Expand Up @@ -21,7 +21,8 @@ import ModulesList from './ModulesList';
const SIZE_SWITCH_ITEMS = [
{label: 'Stat', prop: 'statSize'},
{label: 'Parsed', prop: 'parsedSize'},
{label: 'Gzipped', prop: 'gzipSize'}
{label: 'Gzipped', prop: 'gzipSize'},
{label: 'Brotli', prop: 'brotliSize'}
];

@observer
Expand Down Expand Up @@ -162,7 +163,9 @@ export default class ModulesTreemap extends Component {
};

@computed get sizeSwitchItems() {
return store.hasParsedSizes ? SIZE_SWITCH_ITEMS : SIZE_SWITCH_ITEMS.slice(0, 1);
return store.hasParsedSizes ?
SIZE_SWITCH_ITEMS.filter(item => item.label !== "Brotli") :
SIZE_SWITCH_ITEMS.slice(0, 1);
}

@computed get activeSizeItem() {
Expand Down Expand Up @@ -317,6 +320,7 @@ export default class ModulesTreemap extends Component {
{this.renderModuleSize(module, 'stat')}
{!module.inaccurateSizes && this.renderModuleSize(module, 'parsed')}
{!module.inaccurateSizes && this.renderModuleSize(module, 'gzip')}
{!module.inaccurateSizes && this.renderModuleSize(module, 'brotli')}
{module.path &&
<div>Path: <strong>{module.path}</strong></div>
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"dependencies": {
"acorn": "^8.0.4",
"acorn-walk": "^8.0.0",
"brotli-size": "^4.0.0",
"chalk": "^4.1.0",
"commander": "^7.2.0",
"gzip-size": "^6.0.0",
Expand Down
3 changes: 3 additions & 0 deletions src/analyzer.js
Expand Up @@ -3,6 +3,7 @@ const path = require('path');

const _ = require('lodash');
const gzipSize = require('gzip-size');
const brotliSize = require('brotli-size');

const Logger = require('./Logger');
const Folder = require('./tree/Folder').default;
Expand Down Expand Up @@ -103,6 +104,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
if (assetSources) {
asset.parsedSize = Buffer.byteLength(assetSources.src);
asset.gzipSize = gzipSize.sync(assetSources.src);
asset.brotliSize = brotliSize.sync(assetSources.src);
}

// Picking modules from current bundle script
Expand Down Expand Up @@ -157,6 +159,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
statSize: asset.tree.size || asset.size,
parsedSize: asset.parsedSize,
gzipSize: asset.gzipSize,
brotliSize: asset.brotliSize,
groups: _.invokeMap(asset.tree.children, 'toChartData')
}));
}
Expand Down

0 comments on commit 7181f59

Please sign in to comment.