# component-builder

> builder for component

Latest version **1.2.1** (published 2015-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install component-builder
pnpm add component-builder
yarn add component-builder
bun add component-builder
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-03-09 |
| First published | 2012-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Jonathan Ong |
| Maintainers | tjholowaychuk, jongleberry, dominicbarnes, tootallnate, rauchg, retrofox, coreh, forbeslindesay, kelonye, mattmueller, yields, anthonyshort, ianstormtaylor, cristiandouce, swatinem, stagas, amasad, juliangruber, shtylman, calvinfo, blakeembrey, timoxley, jonathanong, queckezz, nami-doc, clintwood, thehydroimpulse, stephenmathieson, trevorgerhardt, timaschew, jasonkuhrt |

## Links

- npm: https://www.npmjs.com/package/component-builder
- Repository: https://github.com/component/builder2.js
- Issues: https://github.com/component/builder2.js/issues
- npm.io page: https://npm.io/package/component-builder

## Dependencies (12)

- [co](https://npm.io/package/co.md) ^3.1.0
- [cp](https://npm.io/package/cp.md) ^0.1.1
- [debug](https://npm.io/package/debug.md) *
- [chanel](https://npm.io/package/chanel.md) ^2.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.3.5
- [requires](https://npm.io/package/requires.md) ^1.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^2.0.3
- [syntax-error](https://npm.io/package/syntax-error.md) ^1.1.1
- [component-flatten](https://npm.io/package/component-flatten.md) ^1.0.1
- [component-manifest](https://npm.io/package/component-manifest.md) ^1.0.0
- [component-require2](https://npm.io/package/component-require2.md) ^1.0.1
- [generator-supported](https://npm.io/package/generator-supported.md) ~0.0.1

## Recent versions

- 1.2.1 (latest) — 2015-03-09
- 1.2.0 — 2014-12-19
- 1.1.13 — 2014-10-05
- 1.1.12 — 2014-09-26
- 1.1.11 — 2014-09-13
- 1.1.10 — 2014-08-08
- 1.1.9 — 2014-07-17
- 1.1.8 — 2014-07-16
- 1.1.7 — 2014-06-18
- 1.1.6 — 2014-05-29
- 1.1.5 — 2014-04-22
- 1.1.4 — 2014-04-20
- 1.1.3 — 2014-04-17
- 1.1.2 — 2014-04-07
- 1.1.1 — 2014-04-06
- … 46 more at https://npm.io/package/component-builder/versions

## README

# component-builder2 [![Build Status](https://travis-ci.org/componentjs/builder2.js.png)](https://travis-ci.org/componentjs/builder2.js)

Another version of component's builder. Some differences:

- Everything is streaming!
- Split into multiple builders
- Much leaner `require` implementation
- Handles newer features like globs
- Fixes a lot of issues with the previous builder

Depends on:

- [resolver](https://github.com/component/resolver.js) - resolved dependency tree
- [flatten](https://github.com/jonathanong/flatten.js) - flatten the dependency tree to create a build order
- [require2](https://github.com/component/require2) - this builder's `require()` implementation.
- [manifest](https://github.com/component/manifest.js) - unglobs components' fields and creates `file` objects suitable for plugins
- [builder-es6-module-to-cjs](https://github.com/component/builder-es6-module-to-cjs) - the included ES6 -> CJS plugin

You may be interested in:

- [bundler](https://github.com/component/bundler.js) - create multiple bundles from the resolved dependency tree

## Installation

    npm install --save-dev component-builder
    
_NOTE_: Don't use the npm repo ~~[component-builder2](https://www.npmjs.org/package/component-builder2)~~ anymore. You get both versions [component/builder.js](https://github.com/component/builder.js) and [component/builder2.js](https://github.com/component/builder2.js) at this npm repo now: [component-builder](https://www.npmjs.org/package/component-builder)

## Example

```js
var fs = require('fs');
var resolve = require('component-resolver');
var build = require('component-builder');

// resolve the dependency tree
resolve(process.cwd(), {
  // install the remote components locally
  install: true
}, function (err, tree) {
  if (err) throw err;

  // only include `.js` files from components' `.scripts` field
  build.scripts(tree)
    .use('scripts', build.plugins.js())
    .end(function (err, string) {
      if (err) throw err;
      fs.writeFileSync('build.js', string);
    });

  // only include `.css` files from components' `.styles` field
  build.styles(tree)
    .use('styles', build.plugins.css())
    .end(function (err, string) {
      if (err) throw err;
      fs.writeFileSync('build.css', string);
    });

  // only copy `images` to the build folder
  build.files(tree)
    .use('images', build.plugins.symlink())
    .end(); // callback optional
})
```

## Builders

There are three types of builders:

- [`scripts`](https://github.com/component/builder2.js/blob/master/docs/scripts.md) - streaming builder for the `Javascript` file.
- [`styles`](https://github.com/component/builder2.js/blob/master/docs/styles.md) - streaming builder for the `CSS` file.
- [`files`](https://github.com/component/builder2.js/blob/master/docs/files.md) - channel-based builder for everything else, which generally means copying or symlinking

You'll also want to read docs on [`builder`](https://github.com/component/builder2.js/blob/master/docs/builders.md), which all three builders above inherit from.

See the documentation for more information on each.

## License

The MIT License (MIT)

Copyright (c) 2014 Jonathan Ong me@jongleberry.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

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