Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for NPM 3+ #4

Open
siddharthkp opened this issue Oct 27, 2016 · 3 comments
Open

Support for NPM 3+ #4

siddharthkp opened this issue Oct 27, 2016 · 3 comments

Comments

@siddharthkp
Copy link

siddharthkp commented Oct 27, 2016

Hey, landed here from (this comment on the npm repo)[https://github.com/npm/npm/issues/10361#issuecomment-247862042]

When I run kit deps in my repo, i only get size of modules in my package.json, not the modules that these depend on internally. Basically, only one level of depth.

Ideally, this should follow the tree down till the last node of the tree to calculate the actual size?
Please correct me if I misunderstood 😄

I'm on node 6.4.0 and npm 3.10.7

Using this on auto-install

auto-install$ kit deps
  [email protected]                 56.6 KB    0.028 seconds
  [email protected]    4.56 KB    0.002 seconds
  [email protected]          4.74 KB    0.002 seconds
  [email protected]                  8.73 KB    0.004 seconds
  [email protected]         7.07 KB    0.003 seconds
  [email protected]             78.3 KB    0.039 seconds
  [email protected]        6.12 KB    0.003 seconds
  [email protected]             196.45 KB  0.098 seconds
  [email protected]                211.71 KB  0.105 seconds
  [email protected]               28.77 KB   0.014 seconds
  [email protected]            19.02 KB   0.009 seconds
  [email protected]            14.88 KB   0.007 seconds

Altogether, dependencies weigh in at 636.99 KB
@mikermcneil
Copy link
Owner

@siddharthkp hmm, I'm not sure-- I use NPM 2, so it always does that for me by default. In NPM 3, all of your dependencies are on the top level, so I definitely could see how that'd cause trouble :/

I'm down to set up something to solve that problem, probably'll want to do it as a pass which recursively crawls the package.json files (trying for the nested node_modules folders first for npm 2 support, and then falling back to the higher level node_modules folders for npm 3 support). The idea being to get where we've got a dictionary mapping package identifiers/installed versions to where they're located, relative from the top-level directory (e.g. { '[email protected]': 'node_modules/whatever/node_modules/glob/' } }). Then from there, it's a matter of going through and duing them to accumulate the proper weight.

So.. ick. I think I can do it, but it'd be good to have a bit more insight on exactly where NPM 3 can put things first (something that's plaguing me as far as the auto npm linking we do when people create new Sails apps via the CLI-- had to straight up disable it for npm 3, which sucks)

@siddharthkp
Copy link
Author

siddharthkp commented Nov 10, 2016

@mikerncneil Hey, I ended up creating one of my own!

https://github.com/siddharthkp/cost-of-modules

Feedback welcome :)

@mikermcneil
Copy link
Owner

@siddharthkp sweet! I'll check it out

@mikermcneil mikermcneil changed the title Does it recursively calculate size of node_modules Support for NPM 3+ Jul 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants