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.

Version 8.0.2 broke my build with gulp

See original GitHub issue

Not sure weather this is a browserify issue, but versions prior to 8.0.2 used to work fine (including 8.0.1).

Now it exits with this error:

Error: write after end
    at writeAfterEnd (D:\code\webgis\node_modules\browserify\node_modules\labeled-stream-splicer\node_modules\stream-spl
icer\node_modules\readable-stream\lib\_stream_writable.js:161:12)

Here is my build code:

var browserify = require('browserify');
var rename = require('gulp-rename');
var transform = require('vinyl-transform');
var reactify = require('reactify');
var size = require('gulp-size');
gulp.task('scripts-debug', function () {
    var browserified = transform(function (filename) {
        var b = browserify(filename, {
            debug: true,
            extensions: ['.js', '.jsx']
        });
        b.transform(reactify);
        return b.bundle();
    });

    gulp.src('src/js/app.js')
        .pipe(browserified)
        .pipe(rename('bundle.js'))
        .pipe(gulp.dest('build/js'))
        .pipe(size({ showFiles: true }));
});

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:36 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
aymanradycommented, Feb 1, 2015

I got around this without vinyl-transform or vinyl-source-stream

gulp.src('./src/index.js')
    .pipe(through2.obj(function (file, enc, next){
            browserify(file.path)
                .transform('stripify')
                .bundle(function(err, res){
                    // assumes file.contents is a Buffer
                    file.contents = res;
                    next(null, file);
                });
        }))
    .pipe(gulp.dest('./build/'))

hope this helps

1reaction
aymanradycommented, Feb 18, 2015

that only works if you have 1 entry file per bundle, right?

@jmm you can create a bundle from multiple entries, here is a rudimentary example on how to achieve that

gulp.task( 'default', function() {
    var bundler = function() {
        var b = browserify(),
            stream = through2.obj( function( file, enc, next ) {
                // add each file to the bundle
                b.add( file.path );
                next();
            }, function( next ) {
                b.bundle( function( err, src ) {
                    // create a new vinyl file with bundle contents
                    // and push it to the stream
                    stream.push( new vinyl( {
                        path: 'bundle.js', // this path is relative to dest path
                        contents: src
                    } ) );
                    next();
                } );
            } );
        return stream;
    };
    return gulp.src( 'src/js/**/*.js' )
            // multiple entry files going to bundler
            // you can apply jslint, jsbeautify on src files here
            .pipe( bundler() )
            // single bundle file
            // apply minification or/and rename bundle file here
            .pipe( gulp.dest( 'build/js' ) );
} );
Read more comments on GitHub >

github_iconTop Results From Across the Web

CI Build broken by Gulp Error - Visual Studio Feedback
Today when we queue a build, the gulp step is throwing an error: ... Gulp Description : Node.js streaming task based build system...
Read more >
Gulp task with babel and browserify + catching errors
1 Answer 1 · I try to use 'gulp y way', but this issue stopped me: github.com/substack/node-browserify/issues/1191 Do you have work example with ......
Read more >
@microsoft/gulp-core-build | Yarn - Package Manager
gulp -core-build is a set of utility functions that makes it easy to create gulp-based build rigs. Instead of having unweildy unmaintainable ...
Read more >
Ioni-cli v6.10.1 with v1 App cannot load gulp or run sass task
I just ported and rebuilt my Ionic v1 app on a new mac and have all the latest and greatest versions of Node,...
Read more >
Apple Releases iOS 8.0.2 to Fix Bugs in Bug-Fixing Update
Apple has issued a new update to fix glitches in iOS 8.0.1, the version that was supposed to fix glitches in iOS 8....
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