privatenumber / pkg-size.dev

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

Inconsistent bundle size results with Bundlephobia #3

Closed Theofilos-Chamalis closed 1 year ago

Theofilos-Chamalis commented 1 year ago

Trying a commonly used dependency as an example, I have stumbled upon a disparity on bundle sizes between Bundlephobia (https://bundlephobia.com/) and Pkg-size (https://pkg-size.dev/). The library in question is axios and the results are the following:

Which of those 2 solutions is the correct one? What is the reason behind this disparity?

Thanks!

privatenumber commented 1 year ago

It's hard to say since I can't confirm Bundlephobia's output, but it looks like they use Webpack to bundle, and Terser (or esbuild) to minify: https://github.com/pastelsky/package-build-stats/blob/ed3de6ceed4e412d7fbed1540718d0fd71797e9a/src/utils/build.utils.ts#L103

Pkg-size uses esbuild to build and minify.

There isn't a significant minification discrepancy between Terser and esbuild: https://github.com/privatenumber/minification-benchmarks

But there might be in the bundling process?

So users can verify the build output themselves, I just added a Download button:

Theofilos-Chamalis commented 1 year ago

Closing this, since an appropriate explanation was given.