ranyitz/qnm

Add pnpm support?

Opened this issue · 8 comments

This looks like a nice tool but it doesn't seem to work with pnpm installations (we, specifically, use Yarn 3 & its pnpm linker but I guess using the pnpm CLI itself would have the same problem).

The output is just this:

$ npx qnm
node_modules directory is empty

Hey @borekb and thanks for opening this issue!

I've looked into this use case and added support for both yarn-3 with pnpm linker, pnpm and the case of circular symlinks.

on qnm version 2.10.0

Please let me know if it works for you

Wow that was fast!

I tried in our repo which uses Yarn workspaces and it failed after about 1 minute with this error:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

I guess Yarn workspaces might be the problem. I don't really have a non-workspaces project I could test right now but still appreciate your super-fast reaction!

Hey @borekb, thanks for testing it!

Actually, qnm supports yarn workspaces, I'm not sure what is the issue 🤷‍♂️
I'd love to debug it though, so if you can find a repo that reproduces it be happy to debug it.

It's an internal repo, unfortunately, and I can't promise that I'll remember to create a public repro 😄. But you're awesome for adding pnpm support so quickly!

The pnpm support seems to only recognize the top-level dependencies from my testing of running qnm in any repo using pnpm

@beeequeue can you create a repro and describe what do you expect to see in oppose to what qnm shows today? I believe it could help shape the output according to what's relevant for the use case

https://github.com/BeeeQueue/qnm-repro

If you install using npm it shows 700~ deps, and if you remove node_modules and install using pnpm it shows 8

Thanks @beeequeue.

You are right. While I made qnm not crash on pnpm repositories, what it does is just list the top-level modules within the node_modules.

pnpm works differently from npm/yarn in a way that it'll create links for every package, and it will place its own dependencies as its siblings

image

Today, qnm's algorithm is to run on a workspace and analyze it from top to bottom, it doesn't try to go "up" in the directory structure like Node's resolution algorithm does.

This is the reason you see only 8 dependencies when running qnm today.


qnm was created because, for years, package managers compromised on correctness for install size by hoisting packages, which created many problems that needed to be debugged. As I'm not a pnpm user myself, it would be very interesting for me to know what kind of things pnpm users need to debug, and what information they expect to get from qnm.

Once I'll understand the need, it would be possible to implement a solution for it.