bundle-collapser
convert bundle paths to IDs to save bytes in browserify bundles
example
The easiest way to use bundle-collapser is from the plugin:
$ browserify -p bundle-collapser/plugin main.js
Instead of the usual output which would have the original require('./foo.js')
style calls in it, the output just has require(2)
style paths, which minifies
more compactly:
{{if!noif!tovar a=typeof require=="function"&&require;if!u&&areturn ;ifireturn ;var f="Cannot find module '"+o+"'";throw fcode="MODULE_NOT_FOUND"fvar l=no=exports:{};to0return noexports}var i=typeof require=="function"&&require;forvar o=0;o<rlength;o++;return s}1:{module { return n * 5 }}{}2:{var bar = ;module { return }}{}3:{var foo = ;var bar = ;console;}{}{}3;
api
You can use bundle-collapser from the api too:
var collapse = ;var fs = ;var src = fs;;
usage
There is also a command-line program included in this distribution:
usage: bundle-collapser {FILE | -} {OPTIONS}
Collapse a browser-pack/browserify bundle from STDIN or a FILE.
OPTIONS:
-h --help Show this message.
methods
var collapse =
var stream = collapse(src)
Return a readable stream
of output from
browser-pack with the input source
string src
converted to have its require()
calls collapsed down to the
dependency targets in the "deps" fields from the unpacking.
install
With npm, to get the library do:
npm install bundle-collapser
and to get the command-line program do:
npm install -g bundle-collapser
license
MIT