3 ms·
Npm does one thing particularly clever that a lot of other library / dependency infrastructures fail at: it supports multiple versions of the same library livin
by shadowgovt 4y ago
Npm does one thing particularly clever that a lot of other library / dependency infrastructures fail at: it supports multiple versions of the same library living in the codebase.
Because npm treats package dependencies recursively, a package depending on v1 of another package and a package depending on v2 of that package can actually live in the same codebase (with proper configuration; it comes as kind of a side-effect of transpilation and tree-shaking requiring the toolchain to rename symbols anyway, so the two different versions of the library just end up either properly hidden via module inclusion or in the same codebase but name-mangled to different things). This isn't foolproof (if one of those libraries leaks details of its dependency, and another piece of code tries to do `instanceof`, it's going to have a bad time), but it makes it easier to work with codebases one doesn't control.