jsdf / browserify-incremental

incremental rebuild for browserify
175 stars 13 forks source link

Doesn't work if .pipe() not called #38

Open bclinkinbeard opened 7 years ago

bclinkinbeard commented 7 years ago

Vanilla browserify allows you to do b.bundle(cb) and get the bundle passed into cb, but with browserify-incremental the callback will only be called if .pipe(someStream) is included.

This code works:

var fs = require('fs');
var browserifyInc = require('browserify-incremental');

var b = browserifyInc({
  entries: ['entry.js'],
  cache: {},
  packageCache: {},
  fullPaths: true,
  cacheFile: 'cache.json'
});

b.on('log', console.log.bind(console));
bundle();

function bundle() {
  b.bundle().pipe(fs.createWriteStream('output.js'));
}

but if bundle is changed to b.bundle(), the cache file is never written and therefore incremental builds do not work.

Is this a bug or am I missing some valid reason this has to happen? If it's expected behavior it should probably be documented.