convert bundle paths to IDs to save bytes in browserify bundles
The easiest way to use bundle-collapser is from the plugin:
$ browserify -p bundle-collapser/plugin main.jsInstead 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;You can use bundle-collapser from the api too:
var collapse = ;var fs = ; var src = fs;;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. var collapse = 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.
With npm, to get the library do:
npm install bundle-collapserand to get the command-line program do:
npm install -g bundle-collapserMIT