Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Bundle CommonJS/Node.js modules for web browser
JavaScript Smarty Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
test
.gitignore
.lint
.travis.yml
CHANGES
LICENCE
Makefile
README.md
package.json

README.md

modules-webmake - Bundle CommonJS modules for web browser

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/

Installation

$ npm install -g webmake

Usage

From the shell:

$ 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.

Optionally you may output modules as source maps.

$ webmake --sourcemap path/to/program-module.js path/to/output.js

It works very well in webkit web inspector but it's not that well supported by firebug

Programmatically:

var webmake = require('webmake');
webmake('/path/to/program-module.js', function (err, source) {
    if (err) {
        // handle eventual error
    }
    // Do whatever you need with generated source
});

Options:

You can pass additional options:

webmake(inputPath[, options], callback);
output: string

Path of output file, if you want webmake to create one

include: string|Array

Additional module(s) that need to be included (but due specific reasons can't be picked by parser).

sourcemap: boolean

Generate source maps.

Limitations

Application calculates dependencies via static analysis of source code (with help of find-requires module)

Supported are relative paths and outer packages paths

This will work:

require('./module-in-same-folder');
require('./module/path/deeper');
require('./some/very/very/very/long' +
    '/module/path');
require('../../module-path-up'); // unless it doesn't go out of current package scope
require('other-package');
require('other-package/lib/some-module);

Absolute paths won't work (TODO)

require('/Users/foo/projects/awesome/my-module');

Different versions of same package will colide (TODO)

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.

Tests Build Status

Before running tests make sure you've installed project with dev dependencies npm install --dev

$ npm test
Something went wrong with that request. Please try again.