pastelsky / bundlephobia

🏋️ Find out the cost of adding a new frontend dependency to your project
https://bundlephobia.com
MIT License
8.92k stars 221 forks source link

Incorrect size counting for ESM source using `.mjs` extension #752

Open zchenwei opened 1 year ago

zchenwei commented 1 year ago

Package name

@aws-amplify/ui-react

Describe the bug

We recently updated our module export from index.js to index.mjs at v4.3.6 to get better ESM support in Node env but we notice that there is an unreasonable size bump for the package on BundlePhobia. As you can see below, the package size of v4.3.6 is almost 2x the size of previous versions. To clarify, we did not add any dependencies or new entry points. We just updated the file extension from .js to .mjs.

Screen Shot 2023-02-03 at 3 11 04 PM

To Reproduce

We published the same source to a node-esm tag but changing the module export extension back to .js. The package size then on BundlePhobia looks normal.

Screen Shot 2023-02-03 at 3 09 50 PM

Screen Shot 2023-02-03 at 2 32 40 PM

Therefore, we think BundlePhobia has trouble handling .mjs files and cannot calculate the right package size for module export using .mjs extension. If you need more info from us, feel free to contact or visit @aws-amplify/ui-react

Expected behavior

BundlePhobia should calculate the right size for ESM export using .mjs extension without double/triple counting its dependencies and the entire package size bump should be minor.