andresz1 / size-limit-action

Compare the real cost to run your JS app or lib to keep good performance in every pull request
ISC License
451 stars 84 forks source link

The comment might be misleading when size limit fails #106

Open ad1992 opened 1 year ago

ad1992 commented 1 year ago

Below is the result json after running size-limit

[
  {
    "name": "dist/excalidraw.production.min.js",
    "passed": false,
    "size": 286003,
    "sizeLimit": 285000,
    "running": 0.06112,
    "loading": 5.58599609375
  },
  {
    "name": "dist/excalidraw-assets/locales",
    "passed": true,
    "size": 267745,
    "sizeLimit": 270000,
    "running": 0.017186666666666666,
    "loading": 5.[229](https://github.com/excalidraw/excalidraw/actions/runs/5659242959/job/15332367714?pr=6803#step:6:230)39453125
  },
  {
    "name": "dist/excalidraw-assets/vendor*.js",
    "passed": true,
    "size": 28735,
    "sizeLimit": 30000,
    "running": 0.021683333333333336,
    "loading": 0.561[230](https://github.com/excalidraw/excalidraw/actions/runs/5659242959/job/15332367714?pr=6803#step:6:231)46875
  }
]

As you can see the size is exceeded for excalidraw.production.min.js

However in the comment posted by size-limit, this is what is shown

Screenshot 2023-07-26 at 8 45 20 AM

And its not clear as the size 279.33 kB is within the limit of excalidraw.production.min.js (285 kB)

ad1992 commented 1 year ago

Any update on this ?

ad1992 commented 1 year ago

Alright so digged more in to this and this line seems to be the culprit https://github.com/andresz1/size-limit-action/blob/master/src/SizeLimit.ts#L32

bytes npm package considers 1KB = 1024 bytes where as

1KB = 1000 bytes
1KIB = 1024 bytes

and since size-limit itself accepts in KB so its better if we just divide by 1000 here instead to sync with the actual size-limit result.