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
[ENHANCEMENT] Improve readability of asset-size printer and include Brotli sizes #10044
Conversation
@@ -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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 })); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
73a51af
to
bf2f41d
Compare
Human readable output:
JSON output:
brotliSize
field for each fileDownside: The addition of the Brotli size slows down the generation of asset sizes.
Closes #10023.