pack node-style source files from a json stream into a browser bundle
npm install browser-packpack node-style source files from a json stream into a browser bundle

json input:
`` json`
[
{
"id": "a1b5af78",
"source": "console.log(require('./foo')(5))",
"deps": { "./foo": "b8f69fa5" },
"entry": true
},
{
"id": "b8f69fa5",
"source": "module.exports = function (n) { return n * 111 }",
"deps": {}
}
]
bundle script:
` js`
var pack = require('browser-pack')();
process.stdin.pipe(pack).pipe(process.stdout);
process.stdin.resume();
output:
``
$ browser-pack < input.json
(function(p,c,e){function r(n){if(!c[n]){c[n]={exports:{}};p[n]0{return r(p[n][1][x])},c[n],c[n].exports);}return c[n].exports}for(var i=0;i
` js`
var pack = require('browser-pack');
Return a through stream that takes a stream of json input and produces a stream
of javascript output. This module does not export its internal require()'var require='
function but you can prepend to the stream contents to get therequire()
require function. will return undefined when a module hasn't been
defined to support splitting up modules across several bundles with custom
fallback logic.
If opts.raw is given, the writable end of the stream will expect objects to be
written to it instead of expecting a stream of json text it will need to parse.
If opts.sourceMapPrefix is given and source maps are computed, theopts.sourceMapPrefix string will be used instead of //#.
If opts.sourceRoot is given and source maps are computed, the root for the
output source map will be defined. (default is no root)
Additionally, rows with a truthy entry may have an order field that
determines the numeric index to execute the entries in.
You can specify a custom prelude with opts.prelude but you should really knowprelude.js
what you're doing first. See the file in this repo for the defaultopts.preludePath
prelude. If you specify a custom prelude, you must also specify a valid to the prelude source file for sourcemaps to work.
opts.standalone external string name to use for umd
opts.standaloneModule sets the internal module name to export for standalone
opts.hasExports whether the bundle should include require= (or theopts.externalRequireName) so that require() is available outside the bundle
With npm, to get the library do:
``
npm install browser-pack
and to get the command-line tool do:
```
npm install -g browser-pack
MIT