Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shows brotli size in report #504

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions client/components/ModulesTreemap.jsx
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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