privatenumber / pkg-size.dev

📦🔍 Find the true size of an npm package
https://pkg-size.dev
688 stars 6 forks source link

bug: respect tree-shaking #10

Closed jeetiss closed 1 year ago

jeetiss commented 1 year ago

tree-shaking doesn't work for some reason, so it is impossible to test anything

size of hexToString from viem package with pkg-size is 87KB, but it is wrong https://pkg-size.dev/viem

👉🏻 snapshot Снимок экрана 2023-07-19 в 19 52 07

size of hexToString from viem package with bundlejs is 3.63 kB, and it is close to true https://bundlejs.com/?q=viem&treeshake=%5B%7BhexToString%7D%5D

👉🏻 snapshot Снимок экрана 2023-07-19 в 19 52 22
privatenumber commented 1 year ago

This is happening a result of esbuild creating unused chunks when splitting is enabled: https://github.com/evanw/esbuild/issues/3252

I'm relying on splitting as a performance benefit to get the exports and also do the initial build at the same time, so it's difficult to disable right now.

privatenumber commented 1 year ago

I disabled splitting so you should be able to see accurate results: