2
votes

I've recently made the transition over from Grunt to Gulp. I'm still fairly new however, could anyone tell me what the difference is between using Gulp-Browserify and just using Browserify?

I know Gulp-Browserify has now been blacklisted and I seen a few discussions about it. I was wondering what the Gulp version did that Browserify doesn't?

1
Browserify is a command-line process. Gulp-browserify was a plugin for Gulp that allowed you to use Browserify as part of a Gulp build process. - Andy
@Andy that isn't correct. Browserify has a JS API that the CLI script uses also. There's no need for a gulp plugin. - m59
Has that always been the case? Because at some point there must have been a need for the plugin otherwise why write one? If the API came about later that would suggest why development on the plugin was abandoned. - Andy
I'm pretty sure it has been. However, Browserify still has a bit of setup that has to be done to use with gulp. I can understand using the plugin to automate that. Actually, that makes more sense to me now that I think about it... - m59
@Andy the point of the plugin was to integrate browserify into the gulp pipeline (e.g. reading and emitting vinyl files), which it doesn't do natively. I believe there are also error handling implications. - JMM

1 Answers

3
votes

The difference is that browserify doesn't natively read and emit the vinyl files that the gulp pipeline deals with. gulp-browserify was an adapter for that, and I believe it did some extra things related to error handling. If possible I recommend that for the time being you avoid using gulp-browserify. In gulp 4 there may be a better way to integrate browserify with gulp. For now, see if this works for you:

var vss = require('vinyl-source-stream');

gulp.task('whatever', function () {
  var b = browserify(entry, b_opts)
    .transform(some_xform);

  return b.bundle()
    .pipe(vss('bundle.js'))
    // ... gulp stuff
    .pipe(gulp.dest(dest));
});

This will generally require you to do per-file manipulations with browserify transforms and then only do bundle-level manipulation in the gulp pipeline.

Further reading: gulpjs/gulp#369