jsdf / browserify-incremental

incremental rebuild for browserify
175 stars 13 forks source link

RangeError: Maximum call stack size exceeded #11

Closed axelander closed 9 years ago

axelander commented 9 years ago

I'm trying to use browserify-incremental with gulp but it won't work. When using browserify it works fine but when I change to browserify-incremental i get the following stacktrace:

I tried using different node versions from 0.10 to 0.12.

RangeError: Maximum call stack size exceeded
    at /Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/through2/through2.js:88:16
    at Function.<anonymous> (/Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/through2/through2.js:46:12)
    at Browserify.b.bundle (/Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/index.js:65:32)
    at Browserify.rebundle (/Users/alexander/dev/my-project/gulp/javascripts.js:44:15)
    at Browserify.emit (events.js:107:17)
    at /Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/index.js:124:11
    at /Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/index.js:321:5
    at /Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/node_modules/async/lib/async.js:180:24
    at Object.async.eachLimit (/Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/node_modules/async/lib/async.js:171:12)
    at invalidateModifiedFiles (/Users/alexander/dev/my-project/node_modules/browserify-incremental/node_modules/browserify-cache-api/index.js:306:9)

My code looks like this:

createBundle: function(bundle, config) {
    config = merge({
      production: false,
      watch: true
    }, config);

    var extension = config.production ? '.min.js' : '.js';
    var outputFile = bundle.output + extension;

    var bundler = browserifyInc(bundle.input, {
        extensions: ['.js', '.jsx'],
        transform: [reactify]
      });

    if(config.watch) {
      bundler = watchify(bundler);
    }

    bundler.transform('brfs');

    var rebundle = function() {
      var startTime = new Date().getTime();
      bundler.bundle()
        .on('error', gutil.log.bind(gutil, 'Browserify Error'))
        .pipe(source(outputFile))
          .pipe(buffer())
          .pipe(gulpif(!config.production, sourcemaps.init({loadMaps: true}))) // loads map from browserify file
          .pipe(gulpif(config.production, uglify())) // Uglify if production flag is set
          .pipe(gulpif(!config.production, sourcemaps.write('./'))) // write .map file unless production
        .on('end', function() {
          var time = (new Date().getTime() - startTime) / 1000;
          console.log("Finished browserify on file " + outputFile.cyan + " in " + (time + 's').magenta);
        })
        .pipe(gulp.dest(bundle.dest))
        .pipe(gulpif(!config.production, connect.reload())); // Trigger livereload change
    }
    // Rebuild file on update
    bundler.on('update', rebundle);
    // Initial build
    rebundle();
  }
axelander commented 9 years ago

I had forgotten to pass the watchify.args to browserify which contains

{
  cache: {},
  packageCache: {},
  fullPaths: true
}

And now It's building fast without browserify-incremental.