Re:pnpm: Fast, disk space efficient package manager for Java...
by jrochkind1 on Tuesday April 05, 2022 @04:11PM
(#30924335)
I am so confused about the purpose of a "peer dependency" in the first place then.
[ Parent
| on HN ]
Re:pnpm: Fast, disk space efficient package manager for Java...
by jakubmazanec on Tuesday April 05, 2022 @04:25PM
(#30924542)
You can read here why the peer deps were introduced: https://nodejs.org/es/blog/npm/peer-dependencies/
Imagine this structure of packages:
your-app/
├── dep-a/
│ └── dep-c
├── dep-b
└── peer-dep
Very simplified: `dep-c` is dependency of `dep-a`, so it is installed in its node_modules, but `peer-dep` is peer dependency of `dep-a`, so it is in node_modules of `your-app`. `dep-b` could also define `peer-dep` as its peer dependency, so it is installed only once.
When npm switched to flat node_modules structure, peer deps become somewhat redundant, but not quite. Pnpm, which uses symlinks to achieve proper node_modules structure while avoiding long filenames, combined with auto install of peer deps would be ideal package manager.