This module reads dependencies from a package.json file and produces some JavaScript to make the dependencies available in using.js.
To use this with browserify, just browserify the JS produced by usingify.
npm install -g usingify
usingify package.json > dependencies.js
You can use the usingify(package) function to read the parsed contents of a package.json file:
var usingify = require("usingify").usingify; var fs = require("fs"); var file = "" + fs.readFileSync("package.json"); var package = JSON.parse(file); fs.writeFileSync("dependencies.js", usingify(package));
Or you can use the toUsing(moduleName) function when you get your list of dependencies from elsewhere:
var toUsing = require("usingify").toUsing; var dependencies = ""; ["xmugly", "eases", "transform-js"].forEach(function (name) { dependencies += "\n" + toUsing(name) + "\n"; });