Demodule - CommonJS for the browser!
A simple tool to package javascript files into one using CommonJS module specification.
If you want to structure your browser client code using CommonJS (like NodeJS's 'require()'), this is for you.
- Explicitly define which files to include
- Recursive require() support
- Minimization
Example
This is a sample build script using Demodule.
You can see the full example in the example
folder.
var demodule = require("demodule");
var fs = require("fs");
var dependencies = [
{name:"app", path:"./app.js"},
{name:"underscore", path:"./node_modules/underscore/underscore.js"},
{name:"lib", path:"./lib"},
{name:"foo", path:"./foo"},
];
var entry = 'require("app").run();';
var code = demodule(dependencies, entry, {minify: false, debug:true});
var err = fs.writeFileSync("build/app.js", code);
if (err) { throw(err); }
Installation
Requires NodeJS.
See the example app for usage.