hughsk / vinyl-transform

Use standard text transform streams to write fewer gulp plugins
MIT License
55 stars 7 forks source link

gulp recipe for browserify doesn't work #7

Closed nkzawa closed 8 years ago

nkzawa commented 9 years ago

browserify().bundle() returns a readable stream from v9.0.6, thus the following recipe doesn't work now. I'm not sure whether this issue is what this library should support though.

gulp.task("compile", function() {
return gulp.src("index.js")
  .pipe(transform(function(filename) {
    return browserify(filename).bundle();
  }))
  .pipe(gulp.dest("dist"));
});

_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)

https://github.com/substack/node-browserify/commit/f714ac15461db8c7fb9a53b6aad0441c1dbe9c6b

mrjackdavis commented 9 years ago

I've run into the same problem. Especially annoying since the gulp docs rave about this solution

dhowe commented 9 years ago

Same here...

jdreesen commented 9 years ago

I got the same problem.

davydkov commented 9 years ago

Can be resolved by https://github.com/substack/node-browserify/issues/1198

ericsoco commented 9 years ago

vote / +1 / :+1:

nickleefly commented 9 years ago

Please refer to substack/node-browserify#1191 substack/node-browserify#1044

Katharsas commented 9 years ago

+1 substack/node-browserify#1198 does not work for me:

...\node_modules\vinyl-fs\node_modules\vinyl\index.js:143 throw new Error('File.contents can only be a Buffer, a Stream, or null.');

Edit: This solution works fine for me (removed the watchify part): https://gist.github.com/Sigmus/9253068

Code:

var jsDir, jsDest; //source dir, destination dir, see link for other definitions

function buildScript(file) {
    var props = {entries: [jsDir + file], debug: true};
    var bundler = browserify(props);
    var stream = bundler.bundle();
    return stream.on('error', handleErrors)
        .pipe(source(file))
        .pipe(gulp.dest(jsDest));
}

gulp.task('build-js', function () {
    return buildScript('toplevelscript.js');
});
felixfbecker commented 9 years ago

Same issue. I prefer vinyl-transform over vinyl-source-stream because I don't have to put it at the beginning of my pipeline, I can start my pipeline with gulp.src() and pass that stuff to browserify further down the pipeline.

philkunz commented 9 years ago

+1

coffius commented 9 years ago

+1

jeanbza commented 8 years ago

+1

anthonyjfio commented 8 years ago

+1

myconode commented 8 years ago

+1

mdix commented 8 years ago

+1

niftylettuce commented 8 years ago

+1

bron10 commented 8 years ago

+1

hughsk commented 8 years ago

The recommendations made in the gulp docs are out of my hands, vinyl-source-stream is the most appropriate solution here. I know it feels consistent using vinyl-transform, but it's mostly aesthetic preferences at that point. If you'd really like to fix this, please open an issue for browserify and/or gulp — there's nothing that vinyl-transform can do about it sadly.