factor-bundle-reset-patch
Patch for factor-bundle@2.4.1 to work with watchify.
There is a problem to use 2.4.1
with watchify: output streams are finish
ed after bundle
and thus not writable anymore, so you will run into errors when watchify
fires update
to rebundle
.
To solve this problem, output streams are rebuilt every time reset
.
Example
example/gulpfile.js
var path = ;var gulp = ;var uglify = ;var buffer = ;var gutil = ; var factor = ;var browserify = ;var watchify = ; var source = ;var merge = ;var readonly = ;var del = ; var PassThrough = PassThrough; var fixtures = pathresolve; gulp; gulp; gulp; { return b // from now on, use gulp plugins to transform contents ;} { var entries = 'a.js' 'b.js'; var basedir = ; var b = b; b; b; // make `bundle` return a vinyl stream. // perhaps another plugin to gulpify `bundle` b { var pipeline = ; var common = browserifyprototypebundle ; b; return ; }; return b;}
⌘ tree example/
example/
├── dist
│ ├── a.js
│ ├── b.js
│ └── common.js
├── gulpfile.js
└── src
├── a.js
├── b.js
└── c.js
b.plugin(factor, opts)
opts
entries
Type: Array
Entry file paths. Absolute or relative to opts.basedir
basedir
Type: String
outputs
Type: Array
, String
Output destinations. Passed to opts.createWriteStream
to make output streams.
Type: Function
It receives opts.entries, opts.basedir
, and should return output streams.
createWriteStream
Type: Function
Default: fs.createWriteStream
pack
Type: Function
, browser-plugin
Default: browser-pack
theshold
Same with that in factor-bundle.
events
b.on('factor.pipelines', function(files, pipelines, outputStreams){})
Emits all absolute entry files, pipelines, and output streams.