6.1.0 • Published 6 years ago

browser-pack v6.1.0

Weekly downloads
885,370
License
MIT
Repository
github
Last release
6 years ago

browser-pack

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

build status

example

json input:

[
  {
    "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:

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](function(x){return r(p[n][1][x])},c[n],c[n].exports);}return c[n].exports}for(var i=0;i<e.length;i++)r(e[i]);return r})({"a1b5af78":[function(require,module,exports){console.log(require('./foo')(5))},{"./foo":"b8f69fa5"}],"b8f69fa5":[function(require,module,exports){module.exports = function (n) { return n * 111 }},{}]},{},["a1b5af78","b8f69fa5"])

methods

var pack = require('browser-pack');

pack(opts)

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() function but you can prepend 'var require=' to the stream contents to get the require function. require() 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, the opts.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 know what you're doing first. See the prelude.js file in this repo for the default prelude. If you specify a custom prelude, you must also specify a valid opts.preludePath 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 the opts.externalRequireName) so that require() is available outside the bundle

install

With npm, to get the library do:

npm install browser-pack

and to get the command-line tool do:

npm install -g browser-pack

license

MIT

browserifywenke-browserifyencrypto-browserifybrowserify-extendscript@infinitebrahmanuniverse/nolb-browser-@everything-registry/sub-chunk-1266letv-boss-dthpd-asset-pipelinei18nifykountexampleirae-mendel-outlet-browser-packmonacoremixolydianintreq-streammako-jsmerge-browser-packedmendel-middlewaremendel-outlet-browser-packnguye@soyjak/utils@soapdog/webextify@rstacruz/pnpm@sammacbeth/webextify@sammacbeth/browserify@zdychacek/browserify-babylon@zalastax/nolb-browser-bcx-browserifybeyondcorebenbria-buildasset-pipe-js-readerbitcore-multicoinbit-bundlerbit-bundler-browserpackcommon-bundlecordova-plugin-amplify-paycordova-plugin-amplify-paymentbrocodebrowserify-lite2browserify-minify-module-pathsbrowserify-dynamic-importbrowserify-fbrowserify-debufbrowserify-blentedbrowsyquirebrowserify-testabilitybrowserify-windows-fixbowserifybundle-collapserbundle-collapser-extendednode-serverifyoly-factor-bundleonixcoreproxyquireifyproxyquireify-es3organic-bundlecoderaynost-browserifyowt-client-javascriptpanto-transformer-browserifyperferendisistepd-gulp-jssecurifyvendorifyvideo-multi-uploaderunpathifyunpathify-altyarbuz-factor-bundlesjwcoresmileycoretanngoss-buildrifi-bundlerifi-loadreactjs-github-widgetsplit-requireraynos-browserify@pirxpilot/browserify@cobalt-engine/co-browserifychoo-bundlesclay-proxyquireify@ct-solutions/js-builderdcomposebant-pluginbant@frdl/legacy-and-deprecations-fallbackds-watchifyds-packds-builddumbjsdistillifybeelder@jenkins-cd/js-builder@jenkins-blueocean/js-builder@jimbly/browserifyfenglin-uploader@jzetlen/bowserify@koding/bantfactor-bundlefactor-bundle-WA64@leichtgewicht/browserify
6.1.0

6 years ago

6.0.4

6 years ago

6.0.3

6 years ago

6.0.2

7 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.0.4

9 years ago

4.0.3

9 years ago

4.0.2

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.2.0

9 years ago

3.1.1

10 years ago

3.1.0

10 years ago

3.0.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.11.1

10 years ago

0.11.0

11 years ago

0.10.2

11 years ago

0.10.1

11 years ago

0.10.0

11 years ago

0.9.4

11 years ago

0.9.3

11 years ago

0.9.2

11 years ago

0.9.1

11 years ago

0.9.0

11 years ago

0.8.1

11 years ago

0.8.0

11 years ago

0.7.1

11 years ago

0.7.0

11 years ago

0.6.0

11 years ago

0.5.0

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.0.0

11 years ago