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

[ENHANCEMENT] Improve readability of asset-size printer and include Brotli sizes #10044

Closed

Conversation

bertdeblock
Copy link
Contributor

@bertdeblock bertdeblock commented Oct 4, 2022

Human readable output:

  • Uses a table layout for better readability
  • Sorted based on asset size

Screenshot 2022-10-05 at 10 25 33

JSON output:

  • Contains a new brotliSize field for each file

Screenshot 2022-10-04 at 23 00 31

Downside: The addition of the Brotli size slows down the generation of asset sizes.

Closes #10023.

@bertdeblock bertdeblock self-assigned this Oct 4, 2022
@@ -5,46 +5,48 @@ const path = require('path');
const walkSync = require('walk-sync');
const workerpool = require('workerpool');

module.exports = class AssetPrinterSize {
module.exports = class AssetSizePrinter {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use AssetSizePrinter everywhere else, and the filename is asset-size-printer as well.

constructor(options) {
Object.assign(this, options);
this.outputPath = options.outputPath;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes it clearer what's expected / passed in.

print() {
const { filesize } = require('filesize');
let ui = this.ui;
async print() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to "async - await" for both print functions.

let files = await this.makeAssetSizesObject();

if (files.length !== 0) {
this.ui.writeLine(JSON.stringify({ files }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The showGzipped property was removed, so we can print everything as is.

@@ -0,0 +1,15 @@
'use strict';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File was also renamed from gzipStats.js to gzip-stats.js for consistency.

@bertdeblock
Copy link
Contributor Author

This is fun.

Screenshot 2022-10-05 at 08 37 57

@bertdeblock bertdeblock marked this pull request as draft October 5, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

idea: Report compressed sizes with brotli at 11
1 participant