Aquire
This is aquire, a little node library I've been working on to do asynchronous node module downloading and importing. Whereas previously you'd have to do this:
$ npm install coffee-script@1.7.0
And then this:
coffee = require('coffee-script')
eval(coffee.compile("(-> console.log 'hello, world!')()"))
With aquire you can do it all in one step:
aquire = require('./aquire')
aquire('coffee-script@1.7.0')
.then(function(coffee) {
eval(coffee.compile("(-> console.log 'hello, world!')()"))
})
It invokes npm, installs the module and all its dependencies for you at run time, and then resolves the promise when everything's ready. Modules are cached in a specific aquire_modules
directory so only the first time should be slow.
There are still a few bits to work out, like how to deal with multiple different versions being required simultaneously. I also want to add client-side js support. But for now at least I think it's an interesting take on the various module loading systems.