# promethify

> Browserify plugin async load code like AMD

Latest version **0.1.0** (published 2013-12-26) · MIT license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2013-12-26 |
| First published | 2013-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 47 |
| Author | John K. Paul |
| Maintainers | johnkpaul |
| Keywords | browserify, v3, js, plugin, transform |

## Links

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

## Dependencies (12)

- [q](https://npm.io/package/q.md) ~0.9.7
- [lodash](https://npm.io/package/lodash.md) ~2.2.1
- [mkdirp](https://npm.io/package/mkdirp.md) ~0.3.5
- [through](https://npm.io/package/through.md) ~2.2.7
- [scriptjs](https://npm.io/package/scriptjs.md) ~2.4.0
- [detective](https://npm.io/package/detective.md) ~2.2.0
- [requireify](https://npm.io/package/requireify.md) ~0.1.1
- [innersource](https://npm.io/package/innersource.md) 0.0.2
- [node-static](https://npm.io/package/node-static.md) ~0.7.2
- [find-parent-dir](https://npm.io/package/find-parent-dir.md) ~0.1.0
- [inline-source-map](https://npm.io/package/inline-source-map.md) ~0.2.5
- [combine-source-map](https://npm.io/package/combine-source-map.md) ~0.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.0 (latest) — 2013-12-26
- 0.0.2 — 2013-12-24
- 0.0.1 — 2013-12-22

## README

# promethify

[![build status](https://secure.travis-ci.org/johnkpaul/promethify.png?branch=master)](http://travis-ci.org/johnkpaul/promethify)

Browserify v2+ transform to require AMD style and async fetch bundles with minimal configuration

After you have added the correct configuraton to your package.json, it's as simple as: 

    browserify --transform promethify main.js > bundle.js


## Usage

### Example 1
```javascript

//main.js
var $ = require('jquery');

$('.buy-product').click(function(){
  require(['/shopping-cart'], function(shoppingCart) {
    // only downloaded shopping cart code including jqueryui when necessary
    shoppingCart.open();
  });
});

//shopping-cart.js
var $ = require('jquery');
require('jqueryui');

module.exports = {
  open: function(){
    // open modal with jquery ui
  }
}
```

### Example 2
```javascript
//foo.js

console.log(window.loaded) // undefined

require(['/bar'], function(bar){
  console.log(bar.hello); // async fetch the bar bundle and log 'world'
  console.log(window.loaded); // true
});

//bar.js

module.exports = {hello: 'world'};
window.loaded = true;
```

## Configuration

This transform has two different modes of use.

1. Self hosted. This will spin up a local web server to automatically serve the bundles that are requested on the fly. 
1. Bring Your Own Hosting (BYOH). This will spit out all of the bundles to an output directory that you can serve separately, from a CDN or wherever you'd like. 
Configuration is provided through the package.json of your project. 

Self Hosted configuration:
```
  "promethify": {
    "basedir": "test",
    "hostname": "localhost",
    "port": 8087
  }
```

BYOH configuration:
```
  "promethify": {
    "basedir": "src",
    "hostname": "cdn.yourwebsite.com",
    "outputDir": "out",
    "outputDeployPath": "static/project/releases",
    "port": 8089
  }
```

There are three required properties for either mode. 

1. `basedir` This option is the path from the package.json of your project that you want to use for lookups when requiring files asynchronously. 
2. `hostname` This option is the hostname that will be looked up from the browser
3. `port` This option is the port number that you want the server that asynchronously fetches the new bundles to bind to. 
There are three required properties.

There are two properties that will put promethify into BYOH mode.  If one is used, they are both required.

1. `outputDir` This option is the file system path from the package.json of your project that all of the new bundles will be written into.
2. `outputDeployPath` This option is the path that will be prepended to the bundle names when looked up from the browser.

When in BYOH mode, the browser will make a request that looks like `//hostname:port/outputDeployPath/BUNDLE_NAME` You should make sure to serve the outputDir at the correct path.

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