packagephobia icon indicating copy to clipboard operation
packagephobia copied to clipboard

Feature request: Show a table with sizes

Open siddharthkp opened this issue 7 years ago • 6 comments

I tested this with @auth0/babel-preset-cosmos and got a scary result, but couldn't pin point why

By running cost-of-modules on my machine, I found it was because of one specific dependency: babel-plugin-transform-class-properties

┌───────────────────────────────────────────┬─────────────┬───────┐
│ name                                      │ children    │ size  │
├───────────────────────────────────────────┼─────────────┼───────┤
│ babel-plugin-transform-class-properties   │ 45          │ 8.05M │
├───────────────────────────────────────────┼─────────────┼───────┤
│ babel-plugin-transform-object-rest-spread │ 2           │ 0.06M │
├───────────────────────────────────────────┼─────────────┼───────┤
│ babel-preset-react                        │ 20          │ 0.46M │
└───────────────────────────────────────────┴─────────────┴───────┘

Feel free to close this if it is out of scope.

siddharthkp avatar Apr 09 '18 05:04 siddharthkp

Thanks for the request!

I realize that the way you described this is how cost-of-modules works and the initial reason for this tool diffs slightly as seen in the readme

I will think through this problem a little more and see if I can come up with something. 👍

styfle avatar Apr 09 '18 13:04 styfle

You know the dependencies and their install sizes. It would be nice to list them in each package page. A pie chart would be excellent

mohsen1 avatar Jun 17 '18 19:06 mohsen1

@mohsen1 Kind of 🤔

We know the dependencies and their publish sizes, not their install sizes (unless we run Package Phobia for each dependency which could be very very slow).

This is because of the way npm flattens dependencies after an install which is why @siddharthkp created the cost-of-modules tool. Prior to [email protected], you could just look at the contents of the node_modules folder and see which dependency was largest.

Does that make sense?

styfle avatar Jun 17 '18 23:06 styfle

@siddharthkp @mohsen1 I have a PR in another project that might be what you're looking for:

https://github.com/anvaka/npmgraph.an/pull/27

It would be great if you could give it a look through, thanks! 👍

styfle avatar Jul 25 '18 15:07 styfle

I think just having the package size of each dependency would help a lot, and it's also what bundlephobia does for its graph: https://bundlephobia.com/result?p=@uppy/[email protected] Here at the bottom, engine.io-client is a transitive dependency, but it's listed along with everything else. The ideal situation IMO would be to have a graph like that, that also listed the dependency paths on hover (or elsewhere), so you can see whether a very heavy transitive dependency could be removed by changing just one dependency or if it needs more work.

Trying to estimate the install sizes of each package could be done in a single install by looking at the requires key in package-lock.json, but shared transitive dependencies would add up to more than they're actually worth (eg. lodash being depended on by two different dependencies should not be counted twice).

goto-bus-stop avatar Sep 05 '18 11:09 goto-bus-stop

similar thoughts: https://github.com/styfle/packagephobia/issues/124#issuecomment-417977989

leeoniya avatar Sep 05 '18 13:09 leeoniya