substack/node-browserify — pull request #162 by alexstrat (2012-06-07 15:16:15+00:00)
Title: Global method and related cli option

This is a global method to let modules to be exported as global and the associated cli option. Original idea from @substack in #155 (for `Buffer`).

**Synopsis** :

Require `module` and let it be a global variable.

```js
b.global('jquery')
//-> window.jquery
```

Choose the global variable name :

```js
b.global('jquery', '$')
//-> window.$
```

Let a sub-module (a property) of `module` be the global :

```js
b.global('events', {sub : 'EventEmitter'})
//-> window.EventEmitter
```

Special shortcut for *Buffer* :

```js
b.global('Buffer')
//-> window.Buffer
```

**Cli** :

```bash
$ browserify --global Buffer
```

or

```bash
$ browserify --global jquery:$
```