3 ms·
So, assuming I have two libraries, A and B, that both require the same version of library C, do those libraries still get their own separate in-memory copies of
by vec 11y ago
So, assuming I have two libraries, A and B, that both require the same version of library C, do those libraries still get their own separate in-memory copies of C, or do they share a singleton?
It's terrible practice, but it's not unheard of for an NPM module to monkey patch its dependencies, since before this the library could assume it had sole ownership of its whole subtree.
- mavdi 11y agoInteresting. This would indeed be a problem. I hope they don't share them between modules because if one mutates a dependancy, it would be nearly impossible to debug/fix.
- Killswitch 11y agoIf depend on A and B and both A and B depend on the same version range as C, C is now a top-level dependency. Your node_modules will look like this: - Package_A - Package_B - Package_C It's only when A and B depend on different versions of C that cannot be resolved via semver as safe. - Package_A -- node_modules --- Package_C - Package_B -- node_modules --- Package_C I am pretty certain that monkey patching your dependencies is frowned upon in the Node world. It's best to fork the repo make your changes, and then depend on that.
- randallsquared 11y agoSadly, this is the result of the second situation: - Package_A - Package_C_vX - Package_B -- node_modules --- Package_C_vY