browserify-bypass

browserify middleware to declare alternative requires for the browser

npm install browserify-bypass
1 downloads in the last month

browserify-bypass

A node.js browserify middleware to declare alternative requires for the browser.


Installation

npm install browserify-bypass

Example

To declare an alternative require for the browser write // @browser ./path/to/browserModule.js one line above the require statement:


// @browser ./browserModule.js
var myModule = require("./nodeModule.js"),
// @browser ./anotherBrowserModule.js
    anotherModule = require("./anotherNodeModule.js");

To generate the browserified module just do this:


var b = require("browserify");

b(); // init browserify with default options
b.use(require("browserify-bypass"));
b.require("./testModule.js");

The browserified module will now look like this:


var myModule = require("./browserModule.js"),
    anotherModule = require("./anotherBrowserModule.js");
npm loves you