bundle-stats icon indicating copy to clipboard operation
bundle-stats copied to clipboard

`displayValue` does not match `value` for File Sizes

Open ardelato opened this issue 2 years ago • 2 comments

Description

This problem mainly stems from a dependent package^1 that converts the file sizes in https://github.com/relative-ci/bundle-stats/blob/afe79a3f89f8110c2e6957ed565a5aa4bb3e9824/packages/utils/src/utils/format.js#L9-L17

As a result the displayValue does not match the value.

"name": "save-topic.js.231018ed472196b528b5.js",
"value": 3530,
"isEntry": true,
"isInitial": true,
"isChunk": true,
"chunkId": "3825",
"displayValue": "3.45KB"

There is already an issue on the dependent package^2, but it has been more than 3 years and the issue has not been fixed. I am wondering if the formatFileSize function should be changed to not depend on convert-units for formatting the file sizes?

ardelato avatar Aug 22 '22 19:08 ardelato

Thank you for opening the issue @ardelato, i was not aware about the upstream bug.

Let's see if covert-units is planning to fix it soon.

vio avatar Aug 22 '22 21:08 vio

Hey! I've release a new version 3.0.0-beta.5 which includes a fix for this issue. The release does not contain any breaking changes from version 3.0.0-beta.4 therefore it should be safe to bump the dependency version. Let me know if you have any questions or concerns. @ardelato Did confirm that the fix solves the problem. See this issue for more details. Thanks!

Taar avatar Sep 18 '22 15:09 Taar

@Taar Thank you for the fix! 🙇 I updated the dependency and released a new version: v4.0.7.

@ardelato, thanks for confirming the upstream fix!

vio avatar Sep 25 '22 09:09 vio