# brbower

> a browserify plugin, to enable you require bower components just like node modules

Latest version **0.3.2** (published 2014-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install brbower
pnpm add brbower
yarn add brbower
bun add brbower
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2014-08-17 |
| First published | 2014-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Minglei Tu |
| Maintainers | tminglei |
| Keywords | bower, component, components, browserify, plugin, brbower, debowerify |

## Links

- npm: https://www.npmjs.com/package/brbower
- Repository: https://github.com/tminglei/brbower
- Issues: https://github.com/tminglei/brbower/issues
- npm.io page: https://npm.io/package/brbower

## Dependencies (1)

- [lodash-node](https://npm.io/package/lodash-node.md) ~2.4.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2014-08-17
- 0.3.1 — 2014-08-14
- 0.3.0 — 2014-08-14
- 0.2.0 — 2014-07-25
- 0.1.2 — 2014-07-25
- 0.1.0 — 2014-07-23

## README

brbower
=======

[![NPM](https://nodei.co/npm/brbower.png)](https://nodei.co/npm/brbower/)

Let `brbower` plugin require bower components for you when building bundles, then you can `require` them as normal node modules in application codes.  
You can also provide external config, to guide `brbower` to external some bower components, which is useful when when building multiple bundles.


# install

With [npm](https://npmjs.org) do:

```
npm install brbower
```

# usage
In your task runner like `gulp`, add this plugin to `browserify`:
```javascript
b.plugin('brbower', {
	require: ['*', 'base62/lib/base62'],
	external: {
		exclude: ['comp1', 'comp2']
	}
});
```
_p.s. of course, you can also configure this in node `package.json`._

Then, in js or html codes, you can require it like normal node module:
```
// in xxx.js
var comp1 = require('comp1');
var comp2 = require('alias2');
...

// in xx.html
<div class="container-fluid">
...
</div>
<script type="text/javascript">
  require('domready')(function() {
    var comp1 = require('comp1');
    ...
  });
</script>
```

_**p.s. feel free to use it side by other plugins/transforms, since it's a standard `browerify` plugin, no hack, no change to your codes.**_

# options
![brbower config](https://raw.githubusercontent.com/tminglei/brbower/master/doc/brbower-config.png)

**action:** _string_, guide `brbower` to **require**/**external** specified bower components; available values: `require` | `external`, default `require`  

**action config:** _string array or map object_, available config items: `include` | `exclude` | `alias`, examples:  
a) `['name1', 'name2', ...]` _(p.s. will be treated as `{ include: [name1, name2, ...] }`)_  
b) `{ exclude: ['comp5', 'comp7'], alias: ['comp1:alias1'] }`

_Notes: `name` format: `name[:alias]`, and name can be component name or submodule like 'base62/lib/base62'._

#### _Additional Rules:_
- if options undefined, `{ require: [all bower dependency names] }` will be used
- if options..include undefined, `[all bower dependency names]` will be used
- if both include/exclude and alias declared an alias for a component, declaration in alias will be used

# run test
_You need ensure related node modules (for `brbower`) and bower components (for test codes) installed, then run `npm test`._

For first time, you can do it like this:
```sh
tminglei@T500 ~/repos/brbower $ npm install
...
tminglei@T500 ~/repos/brbower $ cd test
tminglei@T500 ~/repos/brbower/test $ bower install
...
tminglei@T500 ~/repos/brbower/test $ cd ..
tminglei@T500 ~/repos/brbower $ npm test

	> brbower@0.2.1 test ~/repos/brbower
	> mocha


	  ....

	  4 passing (580ms)

tminglei@T500 ~/repos/brbower $
```
# diffenence with `debowerify`
`brbower` and `debowerify` try to resolve same problem, but by different ways.  
_(p.s. in fact, brbower's test codes were copied and modified from `debowerify`, thanks so much ^^)_

**debowerify's way:** analyze every js files of the application, to find/replace require string for bower components with their real paths  
**brbower's way:** pre resolve specified bower components and require them to browserify, then when required, they're already there

#### Comparison of `brbower` and `debowerify`:  
|                             |   brbower                     |  debowerify                                    |
| --------------------------- | ----------------------------- | ---------------------------------------------- |
| require submodules <br> _(in application codes)_ | support <br> _(built-in)_ | support <br> _(built-in)_ |
| require ... in html/template files | OK               | not OK <br> _(since it doesn't anaylze html/template files)_ |
| individual require/external <br> _(in build scripts)_ | easy <br> _(with options)_ | not so easy <br> _(through `bower-resolve`)_ |
| extension type              | plugin                        | transform                                                           |
| work mode                   | synchronous                   | asynchronous <br> _(since it depends on bower's resolving results)_ |
| performance                 | slight and quickly <br> _(~ 2s to build a project of mine)_ | slowly <br> _(13 ~ 14s to build the same project)_ <br> _(since it analyzes every js files of the application)_ |


# history
v0.3.0 (14-Aug-2014):  
1) built-in support for submodules  
2) enhancement: if bower.main undefined, check 'index.js' then 'compname'.js

v0.2.0 (25-July-2014):  
1) added tests  
2) document improvement  
3) logic change: include all components declared in `dependencies` and `devDependencies` of bower.json, not only `dependencies`, if options..include undefined  
4) enhancement: allow to specify workdir, where to determine bower components' home dir; default `process.cwd()`

v0.1.0 (22-July-2014):  
1) first release (works fine in my personal project)

# license

MIT

---
_Source: https://npm.io/package/brbower · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
