by FractalHQ · 4y ago · 0 comments
Also- tangential but I really wish people would stop using require and use ESM whenever possible. I cringe when I see `require` just as much as when I see `var` being used in 2022, but I’m not certain there’s never a good reason not to use ESM.
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.)