4 ms·
If you want to override the dependency of your dependency, then it's your dependency too - so if you were using the javascript approach up there you might have
by nirimda 4y ago
If you want to override the dependency of your dependency, then it's your dependency too - so if you were using the javascript approach up there you might have
var bar = require("bar", {baz: loggingBaz})
var foo = require("foo", {bar})
This is true even if you never otherwise use bar.
This is certainly how peer dependencies work in nix flakes, for instance, where you can say something like
bar = //....
bar.inputs.baz.follows = loggingBaz;
foo = //....
foo.inputs.bar.follows = bar;
Since nix flakes is a package/dependency manager, it generates a lockfile that you could inspect too see what all the dependencies are, and make sure you got it right (oh, I still have two bar's, I must have forgotten to override some other dep). I suppose any compiler that involves a linking stage would in principle be able to generate some comparable output at the language level.
(Apologies for using require and var, but I'm convinced the functional syntax is semantically clearer in this context.)