Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jhnns/browserify-bypass

A node.js browserify middleware to declare alternative requires for the browser
https://github.com/jhnns/browserify-bypass

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

browserify-bypass
=================

A node.js [browserify](https://github.com/substack/node-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:

```javascript

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

To generate the browserified module just do this:

```javascript

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:

```javascript

var myModule = require("./browserModule.js"),
anotherModule = require("./anotherBrowserModule.js");
```