siddharthkp / cost-of-modules

Find out which of your dependencies are slowing you down 🐢
MIT License
2.84k stars 41 forks source link

Create a website #50

Closed styfle closed 6 years ago

styfle commented 6 years ago

Have you thought about creating a website so that someone could link to the report to show the cost of a module?

For example, bundlephobia shows you the webpack size if you included the module. See Example.

It would be great to do something like cost-of-modules.com/result?p=ava@0.24.0 and see that the result is 24 MB.

siddharthkp commented 6 years ago

It probably doesn't fit in this repo but a related parallel project

What are the numbers that you'd like to show?

  1. download size
  2. ?
styfle commented 6 years ago

It probably doesn't fit in this repo but a related parallel project

I created https://github.com/pastelsky/bundlephobia/issues/40 which might be a good place to put this feature if it is not out of scope.

What are the numbers that you'd like to show?

I think the numbers should show the size on disk. The way I normally do this myself is the following:

mkdir ava-example
cd ava-example
npm init -y
npm install --save ava
du -sh

This prints 24 M

Note, I add the suffix -example to avoid the name collision with the package name.

siddharthkp commented 6 years ago

I was going to say something similar: https://github.com/pastelsky/bundlephobia/issues/40#issuecomment-354299108

the motive of bundlephobia is different but it has all of the code and infra required for this, maybe a fork makes the most sense 😄

styfle commented 6 years ago

@siddharthkp I would like to import this package and use it on the server but it doesn't seem to work.

npm install --save cost-of-modules
var com = require('cost-of-modules');
Error: Cannot find module 'cost-of-modules'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

I thought it might be because of a missing main but I see that in package.json but I realize now that that the problem is caused by index.js not exporting anything.

styfle commented 6 years ago

I started work in this repo if anyone is interested in following:

https://github.com/styfle/packagephobia

siddharthkp commented 6 years ago

Oh yeah, it's because it assumes CLI

You can pull the functionality into a function and export that, should work

styfle commented 6 years ago

@siddharthkp I think that it would require quite a bit of refactoring to cost-of-modules to make the product I want.

The way cost-of-modules works is assuming you have cloned a repo and you are reading all of the installed dependencies.

The tool I want to build is more like bundlephobia in that you get the cost/size via the web interface, before you install anything.

So I think I'm going to develop this as a separate project and think of a different name. Unless you would like to collaborate and share the same name.

styfle commented 6 years ago

Here's what I came up with: https://github.com/styfle/packagephobia

siddharthkp commented 6 years ago

This is so cool!

styfle commented 6 years ago

Thanks for the kind words!

Keep up the great work on cost-of-modules, it's an excellent tool! 👍