dependency-check
dependency-check copied to clipboard
Don't fail when a package refernces itself
A quite frequent pattern is to reference modules inside a package via the package name.
So for example in package called pkg, there are 2 modules: ./lib/module-1.js and ./lib/module-2.js.
module-1 might require module-2 via require('pkg/lib/module-1'). Currently dependency-check will fail on this code with this error:
Fail! Dependencies not listed in package.json: pkg
though it is not an error because pkg is the package inside which the module is.
real-world example: https://github.com/rlidwka/jju/blob/master/lib/utils.js#L24
Can you give an explanation why one would want to do that?
I'm not of the impression that this is a quite frequent pattern, but I'm prepared to be convinced 🙂
Thoughts @blakeembrey?
ok, let me put it another way. It is not frequent but it is used in a few very popular packages. Like for instance in one of the babel packages. I can look for other examples as well.
Hence it is used in a few popular packages, these errors happen frequently because you happen to have one of those in your node_modules.
Can you give an explanation why one would want to do that?
I don't use this pattern but maybe to avoid long relative paths when a package has many subfolders, so instead of doing something like ../../utils, one can do babel/utils
That’s an interesting pattern. It wouldn’t work locally since node module resolution wouldn’t be able to find it, and given that it seems like it definitely should not be enabled by default. Given the similarity of adding a flag for this and using -i, why not just ignore it?