It's about organizing JavaScript code for browser same way as we do for Node.js. Modules rocks
If you're not that familiar with it (yet), see spec: http://www.commonjs.org/specs/modules/1.0/
$ npm install -g webmake
$ webmake path/to/program-module.js path/to/output.js
Program module is the main file in which you require needed stuff and make use of it.
var webmake = require('webmake');
webmake('/path/to/program-module.js', function (err, source) {
// Do whatever you need with generated source
});
Application calculates dependencies by reading require paths from source code
Following won't work:
require('./path/' + 'rest/of/path');
require(readFromVariable);
require(generatePath());
This will work:
require('./module-in-same-folder');
require('./module/path/deeper');
require('../../module-path-up'); // unless it doesn't go out of current package scope
require('other-package');
require('other-package/lib/some-module);
require('/Users/foo/projects/awesome/my-module');
Current dependency parsing is rudimentary, unfortunately following will be picked up:
// require('./well/i/dont/need/that')
var generatedCode = 'var s = require("used/somewhere/else");';
stay tuned, it will be fixed.
Let's say, required package A uses version 0.2 of package C and required package B uses version 0.3 of same package, it will most likely crash. Currently webmake will take C in version that was called first and will give it to both A and B.
- Right dependency parsing (probably with help of UglifyJS)
- Absolute path lookups
- Support different package versions
- Compiled version (no boilerplate code overhead, trimed requires)