question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

9.0.6 breaks my gulp + watchify setup

See original GitHub issue
@Gulpfile.js

var gulp       = require('gulp');
var gutil      = require('gulp-util');
var transform  = require('vinyl-transform');
var debug      = require('gulp-debug');
var browserify = require('browserify');
var watchify   = require('watchify');
var reactify   = require('reactify');
var _          = require('underscore');

var paths = {
  src:  './www/src/',
  dist: './www/dist/'
};

var b = browserify(paths.src + 'js/', _.extend(watchify.args, {debug: true}));
var bundler = watchify(b)
  .transform(reactify)
  .on('update', bundle)
  .on('log', console.error);

console.log(watchify.args);

function bundle() {
  var bundle = transform(function(filename) {
    return bundler.bundle();
  });
  return gulp.src([paths.src + 'js/index.js'])
    .pipe(debug({title: 'bundle'}))
    .pipe(bundle)
    .on('error', gutil.log.bind(gutil, 'Browserify Error'))
    .pipe(gulp.dest(paths.dist));
}

gulp.task('browserify', bundle);

Upgrading to 9.0.6 results in the following error:

_stream_readable.js:540
    var ret = dest.write(chunk);
                   ^
TypeError: undefined is not a function
    at Producer.ondata (_stream_readable.js:540:20)
    at Producer.emit (events.js:107:17)
    at Producer.Readable.read (_stream_readable.js:373:10)
    at flow (_stream_readable.js:750:26)
    at resume_ (_stream_readable.js:730:3)
    at _stream_readable.js:717:7
    at process._tickCallback (node.js:355:11)

9.0.4 works fine

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thepiancommented, Sep 6, 2015

Am I reading this wrong? It seems the objective is to produce multiple bundles and your fix is to make a single bundle.

1reaction
terinjokescommented, Apr 3, 2015

b.bundle() has always been documented* as returning a readable stream. From version to version, sometimes a duplex stream would be returned as an implementation detail, but writing to it was always undefined behavior.

If you must use gulp for this task, use vinyl-source-stream instead of vinyl-transform.

var browserify = require('browserify'),
    gulp       = require('gulp'),
    source     = require('vinyl-source-stream'),
    buffer     = require('vinyl-buffer'),
    uglify     = require('gulp-uglify');

gulp.task('default', function () {
    return browserify([__dirname + '/lib/browserified.js']).bundle()
        .pipe(source('app.js'))
        .pipe(buffer())
        .pipe(uglify())
        .pipe(gulp.dest(__dirname + '/cache'));
});

*Effectively always, starting with version 2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version 8.0.2 broke my build with gulp · Issue #1044 - GitHub
Just a quick note that our build scripts have been broken by this issue too, and we've also had to downgrade ... 9.0.6...
Read more >
Gulp with watchify/browserify runs twice then stops watching
It turned out PHPStorm / System Settings / Use "safe write", if enabled, stops watchify after PHPStorm edits the file.
Read more >
Using Watchify with Gulp for fast Browserify build
I thought I would be able to .pipe(uglify()) in bundleShare() .. but it breaks. Do i need to use vinyl-transform to enable this?...
Read more >
gulp-browserify-watchify-glob - npm
Create a Browserify bundler with multiple entries based on a glob pattern. Rebuild incrementally watching for changes, including additions ...
Read more >
Gulpfile Setup-Automate and Enhance Your Code - YouTube
Ever wondered how other developers minify their code and add tons of enhancements to their projects or apps? I can tell you a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found