[Feature Request] Display package size
styfle opened this issue ยท 5 comments
I am considering writing a tool to do this because it might be outside the scope of this project.
There is already https://bundlephobia.com which is great for front end dependencies that get bundled with webpack but it doesn't tell you about the size of dev dependencies such as test frameworks.
There is already a request to add this to npmjs.com here: npm/www#197
Is this a feature that could be used by npms.io? (forgive me if this is the wrong repo)
Yes we could! We actually have downloaders that are able to download the source code as well as the published code: https://github.com/npms-io/npms-analyzer/tree/master/lib/analyze/download
If there's a module that could receive a directory (that contains the code as well as the package.json) and calculate the bundle size, it would be easy to add the feature.
@satazor Thanks for the response!
I am actually working on code now to be able to do this but wanted to make sure I wasn't re-inventing the wheel! https://github.com/styfle/packagephobia
I started going for a web app to make it similar to bundlephobia but really all it does is act as an API for the module you just described.
Would you like me to break out the logic that computes the size into a separate package so you can save the size in your own database?
Here's what I came up with: https://github.com/styfle/packagephobia
@satazor The API is now available ๐
You can use the npm package name and version (cached result):
https://packagephobia.com/api.json?p=next@5.1.0
Or simply the npm package name which will automatically use the latest version (never cached):
https://packagephobia.com/api.json?p=next
Will this work for npms.io to display a size?