jgoz/factor-bundle — pull request #1 by jgoz (2014-09-06 17:53:12+00:00)
Title: Expose pipeline for output bundles on event

- browserify instance emits ‘factor.pipeline’ event when the pipeline is created
- pipeline uses labeled-stream-splicer and has ‘pack’ and ‘wrap’ stages

Example usage with gulp:

```js
var splicer = require('stream-splicer');

function wrap(id) {
return splicer.obj([
source(path.basename(id)),
buffer(),
sourcemaps.init({ loadMaps: true }),
//uglify(),
sourcemaps.write("."),
gulp.dest('./out')
]);
}

gulp.task('bundle', function () {
var b = browserify([__dirname + '/x.js', __dirname + '/y.js'], { debug: true });
b.on('factor.pipeline', function (id, pipeline) {
pipeline.get('wrap').push(wrap(id));
});
b.plugin(factor);

return b.bundle().pipe(wrap('common.js'));
});
```

I'm not 100% crazy about this solution because it requires the `factor.pipeline` event handler to be attached *before* the `plugin` call.