# q-require

> (out-of-service) asynchronous CommonJS require module loader for Node and browsers

Latest version **0.0.4** (published 2012-06-28) · 0 weekly downloads

## Install

```sh
npm install q-require
pnpm add q-require
yarn add q-require
bun add q-require
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2012-06-28 |
| First published | 2012-06-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.2.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Kris Kowal |
| Maintainers | kriskowal |

## Links

- npm: https://www.npmjs.com/package/q-require
- Repository: https://github.com/kriskowal/q-require
- Homepage: http://github.com/kriskowal/q-require/
- Issues: http://github.com/kriskowal/q-require/issues
- npm.io page: https://npm.io/package/q-require

## Dependencies (3)

- [q](https://npm.io/package/q.md) 0.0.0
- [q-fs](https://npm.io/package/q-fs.md) 0.0.0
- [es5-shim](https://npm.io/package/es5-shim.md) 0.0.1

## Recent versions

- 0.0.4 (latest) — 2012-06-28
- 0.0.0 — 2012-06-28
- 0.0.1 — 2012-06-28
- 0.0.2 — 2012-06-28
- 0.0.3 — 2012-06-28

## README

Q-REQUIRE

Asynchronous CommonJS require module loader for Node and browsers.

The browser implementation is good for development where the
JavaScript is hosted on the same domain of origin as the page, for
live debugging.  For production, it is generally preferable to build
a module transport bundle and to put it on a CDN.


Implements:

 * http://wiki.commonjs.org/wiki/Modules/1.1.1
 * http://wiki.commonjs.org/wiki/Modules/Async/A


Node:

    $ npm install q-require

    var REQUIRE = require("q-require/require");
    var LOADER = require("q-require/loader");

    // construct a require()
    var loader = LOADER.Loader({"paths": [__dirname + "/examples/package/"]});
    var require2 = REQUIRE.Require({"loader": loader});

    // load the main module, asynchronously
    var promise = require2.exec("main");

    var Q = require("q");
    var SYS = require("sys");
    Q.when(promise, function (main) {
        // ok
        SYS.puts(main);
    }, function (reason) {
        // error
        SYS.puts(SYS.inspect(reason));
    });

Browser:

    <script src="require.min.js"></script>
    <script>
        require = Require("path/to/js");
        // async require a main module
        require.exec("main");
        // or
        require.ensure(["foo", "bar", "baz"], function (require) {
            var FOO = require("foo");
            var BAR = require("bar");
            var BAZ = require("baz");
        });
    </script>


This asynchronous loader uses a simple heuristic for analyzing
dependencies; it reads all require calls with string literals.
You'll need to trick the regular expression if you have require
calls that do not imply static dependency, like require((id)).
If you have a dynamic dependency, use require.ensure or
require.exec to asynchronously advance require to include
additional modules and their transitive dependencies.

require.min.js includes ECMAScript 5 shims, so more Object, Array,
String, and Date functions are guaranteed to work.  It also
bootstraps require with the following modules:

 * q
 * require/http
 * require/q-http
 * require/module
 * require/loader
 * require/require

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