# requisite

> A cosmic javascript bundler.

Latest version **1.19.17** (published 2017-06-20) · MIT license · 0 weekly downloads

## Install

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

Provides the command `requisite`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.19.17 |
| Published | 2017-06-20 |
| First published | 2012-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.0 |
| Dependencies | 37 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Zach Kelling |
| Maintainers | zeekay |
| Keywords | analysis, asset, browser, bundle, commonjs, compress, inception, minify, module, modules, require, requirejs |

## Links

- npm: https://www.npmjs.com/package/requisite
- Repository: https://github.com/zeekay/requisite
- Issues: http://github.com/zeekay/requisite/issues
- npm.io page: https://npm.io/package/requisite

## Dependencies (37)

- [url](https://npm.io/package/url.md) ^0.11.0
- [util](https://npm.io/package/util.md) ^0.10.3
- [acorn](https://npm.io/package/acorn.md) 5.0.3
- [clone](https://npm.io/package/clone.md) ^2.1.1
- [vigil](https://npm.io/package/vigil.md) 0.7.3
- [assert](https://npm.io/package/assert.md) 1.4.1
- [broken](https://npm.io/package/broken.md) 0.1.13
- [buffer](https://npm.io/package/buffer.md) 5.0.6
- [events](https://npm.io/package/events.md) 1.1.1
- [process](https://npm.io/package/process.md) 0.11.10
- [inherits](https://npm.io/package/inherits.md) 2.0.3
- [punycode](https://npm.io/package/punycode.md) 2.1.0
- [escodegen](https://npm.io/package/escodegen.md) 1.8.1
- [to-regexp](https://npm.io/package/to-regexp.md) ^0.1.7
- [estraverse](https://npm.io/package/estraverse.md) 4.2.0
- [source-map](https://npm.io/package/source-map.md) 0.5.6
- [strip-debug](https://npm.io/package/strip-debug.md) ^1.1.1
- [os-browserify](https://npm.io/package/os-browserify.md) 0.3.0
- [vm-browserify](https://npm.io/package/vm-browserify.md) ^0.0.4
- [domain-browser](https://npm.io/package/domain-browser.md) 1.1.7
- [string_decoder](https://npm.io/package/string_decoder.md) ^1.0.2
- [tty-browserify](https://npm.io/package/tty-browserify.md) ^0.0.0
- [browser-request](https://npm.io/package/browser-request.md) ^0.3.3
- [browser-resolve](https://npm.io/package/browser-resolve.md) 1.11.2
- [browserify-zlib](https://npm.io/package/browserify-zlib.md) ^0.2.0
- [http-browserify](https://npm.io/package/http-browserify.md) ^1.7.0
- [path-browserify](https://npm.io/package/path-browserify.md) ^0.0.0
- [querystring-es3](https://npm.io/package/querystring-es3.md) ^0.2.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^2.3.0
- [https-browserify](https://npm.io/package/https-browserify.md) 1.0.0
- [crypto-browserify](https://npm.io/package/crypto-browserify.md) ^3.11.0
- [stream-browserify](https://npm.io/package/stream-browserify.md) ^2.0.1
- [timers-browserify](https://npm.io/package/timers-browserify.md) 2.0.2
- [console-browserify](https://npm.io/package/console-browserify.md) ^1.1.0
- [convert-source-map](https://npm.io/package/convert-source-map.md) 1.5.0
- [lodash.escaperegexp](https://npm.io/package/lodash.escaperegexp.md) 4.1.2
- [constants-browserify](https://npm.io/package/constants-browserify.md) ^1.0.0

## 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

- 1.19.17 (latest) — 2017-06-20
- 1.19.16 — 2017-05-04
- 1.19.15 — 2017-04-01
- 1.19.14 — 2017-04-01
- 1.19.13 — 2017-04-01
- 1.19.12 — 2017-02-28
- 1.19.11 — 2017-02-28
- 1.19.10 — 2017-02-23
- 1.19.9 — 2017-02-23
- 1.19.8 — 2017-02-23
- 1.19.7 — 2017-02-23
- 1.19.6 — 2017-02-23
- 1.19.5 — 2017-02-23
- 1.19.4 — 2017-02-23
- 1.19.2 — 2017-02-19
- … 186 more at https://npm.io/package/requisite/versions

## README

# requisite

[![npm][npm-img]][npm-url]
[![build][build-img]][build-url]
[![dependencies][dependencies-img]][dependencies-url]
[![downloads][downloads-img]][downloads-url]
[![license][license-img]][license-url]
[![chat][chat-img]][chat-url]

> Cosmic JavaScript bundling

#### Want ES module support? See [Handroll](https://github.com/zeekay/handroll).

## Introduction
Requisite bundles client-side code and templates. It features asynchronous
module loading for optimal performance of large applications, automatic compiler
detection for several languages and comes with a
[connect][connect]/[express][express] middleware for rapid development.

## Features
- Use CommonJS modules in the browser.
- Customizable compiler/preprocessors.
- Simple API for programmatic usage.
- Lazy asset loading.
- Resolves relative as well as npm modules.
- Command line tool for bundling simple projects.
- Good Source map support.

## Install
```bash
npm install -g requisite
```

## Modules
Requiste allows you to structure your code using [CommonJS (Node.js)
modules][commonjs]. From a given starting point or entry module, requisite will
trace your application's dependencies and bundle all `require`'ed modules
together. Requiste's `require` supports asynchronous loading of assets/modules
when an optional callback argument is provided.

```javascript
// foo.js
module.exports = 'foo';

// async-bar.js
module.exports = 'bar'

// entry.js
console.log(require('./foo'))  // 'foo'
require('./async-bar', function(bar) {
    console.log(bar) // 'bar'
})
```

This compiles down to:

```javascript
// ...prelude, defining require, etc.

require.define('/foo', function (module, exports, __dirname, __filename) {
    module.exports = 'foo';
})

require.define('/main', function (module, exports, __dirname, __filename) {
    console.log(require('/foo'));
    require('/async-bar', function(bar) {
        console.log(bar);
    })
})
```

Note how `async-bar.js` is missing from the bundle, as it's loaded at runtime.

If you are writing a module that can be used both client/server side you can
define the [`browser`](browser-field) field in your package.json and finetune which bits will be
bundled for the client.

## Usage
### CLI
```bash
› requisite

Usage: requisite [options] [files]

Options:

  -h, --help                   display this help
  -v, --version                display version
  -a, --async                  prelude should support async requires
  -b, --bare                   compile without a top-level function wrapper
  -d, --dedupe                 deduplicate modules (when multiple are specified)
  -e, --export <name>          export module as <name>
  -i, --include <module>       additional module to include, in <require as>:<path to module> format
  -g, --global                 global require
  -m, --minify                 minify output
      --minifier               minifier to use
  -o, --output <file>          write bundle to file instead of stdout, {} may be used as a placeholder
  -p, --prelude <file>         file to use as prelude
      --no-prelude             exclude prelude from bundle
      --no-source-map          disable source maps
      --prelude-only           only output prelude
  -s, --strict                 add "use strict" to each bundled module
      --strip-debug            strip `alert`, `console`, `debugger` statements
  -w, --watch                  write bundle to file and and recompile on file changes
  -x, --exclude <regex>        regex to exclude modules from being parsed
      --base                   path all requires should be relative to

Examples:

  # bundle javascript file and all it's dependencies
  $ requisite module.js -o bundle.js

  # bundle several modules, appending .bundle.js to output
  $ requisite *.js -o {}.bundle.js
```

#### Examples
Bundle a javascript file and all it's dependencies:
```
$ requisite module.js -o bundle.js
```

Create several bundles, appending `.bundle.js` to each entry module's name:
```
$ requisite *.js -o {}.bundle.js
```

Create a single shared bundle (to leverage caching in browser) and individual
bundles for each page containing just the additional modules necessary for each:
```
$ requisite --dedupe main.js page1.js page2.js -o {}.bundle.js
```

You'd then use the bundle across the pages of your site like so:
```javascript
// page1.js
<script src="main.bundle.js">
<script src="page1.bundle.js">

// page2.js
<script src="main.bundle.js">
<script src="page2.bundle.js">

// page3.js
<script src="main.bundle.js">
<script src="page3.bundle.js">
```

### API
If you want more fine-grained control over requisite you can require it in your
own projects and use it directly.

```javascript
    require('requisite').bundle({
        entry: __dirname + '/entry.js',
    }, function(err, bundle) {
        fs.writeFileSync('app.js', bundle.toString())
    });
```

### Middleware
For development it can be useful to serve bundles up dynamically, and a connect
middleware is provided for exactly this purpose. Express example:

```javascript
  app.use('/js/app.js', require('requisite').middleware({
    entry: __dirname + '/entry.js'
  }))
```

Which would make your bundle available as `http://host/js/main.js`.

## License
[MIT][license-url]

[browser-field]: https://gist.github.com/defunctzombie/4339901
[coffeescript]:  http://coffeescript.org
[commonjs]:      http://nodejs.org/docs/latest/api/modules.html#modules_modules
[connect]:       http://www.senchalabs.org/connect/
[express]:       http://expressjs.com/
[jade]:          http://jade-lang.com

[build-img]:        https://img.shields.io/travis/zeekay/requisite.svg
[build-url]:        https://travis-ci.org/zeekay/requisite
[chat-img]:         https://badges.gitter.im/join-chat.svg
[chat-url]:         https://gitter.im/zeekay/hi
[coverage-img]:     https://coveralls.io/repos/zeekay/requisite/badge.svg?branch=master&service=github
[coverage-url]:     https://coveralls.io/github/zeekay/requisite?branch=master
[dependencies-img]: https://david-dm.org/zeekay/requisite.svg
[dependencies-url]: https://david-dm.org/zeekay/requisite
[downloads-img]:    https://img.shields.io/npm/dm/requisite.svg
[downloads-url]:    http://badge.fury.io/js/requisite
[license-img]:      https://img.shields.io/npm/l/requisite.svg
[license-url]:      https://github.com/zeekay/requisite/blob/master/LICENSE
[npm-img]:          https://img.shields.io/npm/v/requisite.svg
[npm-url]:          https://www.npmjs.com/package/requisite

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