bro

browsify

Batch convert CommonJS modules into browser compatible ones

Showing:

Popularity

Downloads/wk

20

Maintenance

No Maintenance Data Available

Package

Dependencies

2

Size (min+gzip)

1.0KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Browsify

NPM version

Dependency Status

Batch convert CommonJS modules into a browser compatible package.

Installation

npm install -g browsify

CLI Examples

browsify path/file.js >> modules.js
browsify path/to/files/ >> modules.js
browsify ../../relative/path/lib --truncate-prefix ../../relative/path/ >> modules.js
browsify path/to/files/ --namespace objname >> modules.js

For more options.

browsify -h

Using In Code

npm install browsify

then require the processor module..

var processor = require('browsify').processor,
    opts = {}; // ex: {namespae: "foo"}

processor.compile(["file.js", "file2.js"], opts,  function (str) {
    process.stdout.write(str);
});

Before Running Locally

Use Case Example

browsify lib/foo.js >> modules.js

modules.js looks like:

// browser-require

// for each module
require.define('lib/foo', function (require, module, exports) {
   // actual code defined in lib/foo.js
   module.exports = {
       bar: function () {}
   };
});

..and in the browser you would require the module as expected.

var foo = require('lib/foo');

..or if there was a --namespace ns specified, you would require it as so.

var foo = ns.require('lib/foo');

Versioning

This project ascribes to semantic versioning.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100