Closed terinjokes closed 10 years ago
Merged in 2.1.0.
@terinjokes
While I'm not sure of the practicality of this example, it seemed like a fun little thing to write.
How's this for a practical example? Usage with gulp
:
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var factor = require('factor-bundle');
var gulp = require('gulp');
var merge = require('multistream-merge');
var source = require('vinyl-source-stream');
gulp.task('bundle', function() {
var b = browserify(['./entries/a.js', './entries/b.js']);
var o = [ source('a.js'), source('b.js') ];
b.plugin(factor({ o: o }));
var common = b.bundle().pipe(source('common.js'));
return merge.obj(o.concat(common))
.pipe(buffer()) // not necessary if going straight to gulp.dest
// ...do some kind of post-processing
// extract source-maps, etc...
.pipe(gulp.dest('out'));
});
In conclusion, great change!
@jgoz Which do you think was the real reason for introducing this change? :wink:
I had an inkling :smiley:
So how would you leverage @jgoz solution with watchify?
If using factor-bundle as a Browserify plugin via the API, support piping the factored bundles to a stream, in addition to the current write-to-fs approach.
This allows factor-bundle to more easily utilized within streaming environments.
While I'm not sure of the practicality of this example, it seemed like a fun little thing to write.