I have an app with several page-specific js files and am trying to use factor bundle to create a common js file with their shared dependencies. So far, I can only get browserify and factor-bundle to produce a single file (common.js) that contains all of my js (like a normal browserify bundle). Here is my gulp task:
gulp.task('browserify', function() {
return browserify({
entries: ['./app/client/page1.coffee', './app/client/page2.coffee'],
extensions: ['.coffee', '.jade'],
debug: true
}).plugin('factor-bundle', {
o: ['./public/js/page1.js', './public/js/page2.js']
})
.bundle()
.pipe(source('common.js'))
.pipe(gulp.dest('./public/js/'));
});
This only produces the common.js file in public/js and page1 and page2 are not separate files (they're embedded in common.js).
Expected Results
public/js/page1.js (containing page1.coffee code and any dependencies used only by page1.coffee)
public/js/page2.js (containing page2.coffee code and any dependencies used only by page2.coffee)
public/js/common.js (containing depedencies shared by page1.coffee and page2.coffee)
Removing .plugin(...)
If I remove the .plugin(...)
the modules inside the common.js are in a different order, but byte-for-byte its the exact same size as when .plugin(...)
is present.
Module Info
Browserify (5.9.3)
Factor Bundle (2.1.0)
Vinyl Source Stream (0.1.1)
Gulp (3.8.7)