index.js
function bundleThrough(options) {

  options = options || {}

  var browserifyShouldCreateSourcemaps = options.debug || options.sourcemaps

  var bundleTransform = through(function (file, enc, callback) {

    var bundler = browserify(file.path, assign({}, options, {debug: browserifyShouldCreateSourcemaps}))

    if (options.buffer === false) {

      // if `buffer` option is `false` then `file.contents` is a stream
      return callback(null, createNewFileByContents(file, bundler.bundle().on('error', callback)))

    }

    bundler.bundle(function (err, data) {

      if (err) { return callback(err) }

      callback(null, createNewFileByContents(file, data))

    })

  })

  if (options.sourcemaps !== true) {
    return bundleTransform
  }

  return duplexify.obj(bundleTransform, bundleTransform.pipe(sourcemaps.init({loadMaps: true})))

}
function bundleThrough(options) {

  options = options || {}

  var browserifyShouldCreateSourcemaps = options.debug || options.sourcemaps

  var bundleTransform = through(function (file, enc, callback) {

    var bundler = browserify(file.path, assign({}, options, {debug: browserifyShouldCreateSourcemaps}))

    if (options.buffer === false) {

      // if `buffer` option is `false` then `file.contents` is a stream
      return callback(null, createNewFileByContents(file, bundler.bundle().on('error', callback)))

    }

    bundler.bundle(function (err, data) {

      if (err) { return callback(err) }

      callback(null, createNewFileByContents(file, data))

    })

  })

  if (options.sourcemaps !== true) {
    return bundleTransform
  }

  return duplexify.obj(bundleTransform, bundleTransform.pipe(sourcemaps.init({loadMaps: true})))

}
function bundleThrough ( options ) { options = options || { } var browserifyShouldCreateSourcemaps = options . debug || options . sourcemaps var bundleTransform = through ( function ( file , enc , callback ) { var bundler = browserify ( file . path , assign ( { } , options , { debug : browserifyShouldCreateSourcemaps } ) ) if ( options . buffer === false ) { // if `buffer` option is `false` then `file.contents` is a stream return callback ( null , createNewFileByContents ( file , bundler . bundle ( ) . on ( 'error' , callback ) ) ) } bundler . bundle ( function ( err , data ) { if ( err ) { return callback ( err ) } callback ( null , createNewFileByContents ( file , data ) ) } ) } ) if ( options . sourcemaps !== true ) { return bundleTransform } return duplexify . obj ( bundleTransform , bundleTransform . pipe ( sourcemaps . init ( { loadMaps : true } ) ) ) }
Returns a transform stream which bundles files in the given stream.

@param {object} [options] The options. This options are directly passed to the `browserify` constructor. You can pass any browserify options such as `transform` `plugin` `debug` etc.
@param {boolean} [options.buffer] `true` iff you want output file to have buffer type contents. Default is `true`. If set `false`, the output file has file contents as a stream.
@param {boolean} [options.sourcemaps] `true` iff you want to output sourcemaps. You need to *write* it using `gulp-sourcemaps`.
@return {Transform<Vinyl, Vinyl>}
Returns a transform stream which bundles files in the given stream .