Skip to content

end is never triggered, cache file is never saved #23

@dantman

Description

@dantman

For some reason the cache file is never saved why I try using this.

Versions:

    "babelify": "^7.2.0",
    "browserify": "^12.0.1",
    "browserify-incremental": "^3.0.1",

Node: v0.12.0 (I think)

I'm using this inside of a cordova js hook.

Relevant parts of the code:

var browserify = require('browserify-incremental'),
    b = browserify({cacheFile: path.join(ctx.opts.projectRoot, 'browserify-cache.json')})
        .transform(require('babelify'))
        .require(filePath, {expose: 'app'});

return Q.ninvoke(b, 'bundle')
    .then(function(buf) {
    });

I dug into the code and fiddled around with some console logging.

In this code bundle gets called but end is never called.

  b.on('bundle', function(bundleStream) {
    // store on completion
    bundleStream.on('end', function() {
      storeCache(b, cacheFile);
    });
  });

In this code, if I kill the proxyEvent and pipe and just set outputStream = bundleStream the end event is emitted and the cache file is saved.

      var bundleStream = prevBundle.call(b, cb);
      proxyEvent(bundleStream, outputStream, 'file');
      proxyEvent(bundleStream, outputStream, 'package');
      proxyEvent(bundleStream, outputStream, 'transform');
      proxyEvent(bundleStream, outputStream, 'error');
      bundleStream.pipe(outputStream);

So for some reason the end event isn't being proxied/piped. I tried various things like adding a proxyEvent for it or calling .end() on outputStream in an .on handler for bundleStream. But none of them seemed to work, so I can't figure out what exactly is wrong.

Note that I'm not sure my change would be a proper fix anyways. The cache file was saved and read but I never got any notable speed-up to my compilation of babel+react so I don't know if the caching wasn't working or I need a different browserify cache module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions