简体   繁体   中英

Gulp 4.0 signal async completion error despite returning stream

I have the following gulp task that returns a stream. It works fine in gulp 3.9.1, but converting to gulp 4.0, I get:

Did you forget to signal async completion?

const gulp = require('gulp');
const gulpif = require('gulp-if');
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const buffer = require('vinyl-buffer');
const es = require('event-stream');
const browserify = require('browserify');
const browserifyInc = require('browserify-incremental');
const babelify = require('babelify');
const browserSync = require('browser-sync').create();

// Incrementally building the js
gulp.task('build-js-inc', () =>
  es.merge.apply(null, paths.entry.scripts.map(script => {
    const b = browserify(Object.assign({}, browserifyInc.args,
      {
        entries: script,
        extensions: ['.jsx'],
        debug: true
      }
    ));

    browserifyInc(b, { cacheFile: './browserify-cache.json' });

    return b.transform(babelify)
      .bundle()
        .on('error', handleErrors)
        .pipe(source(`./${script.split('/')[script.split('/').length - 1]}`))
        .pipe(buffer())
        .pipe(plumber())
        .pipe(rename(path => {
          path.extname = '.bundle.js';
        }))
        .pipe(gulp.dest('public/js'))
        .pipe(gulpif('*sw.bundle.js', gulp.dest('public')))
        .pipe(browserSync.reload({ stream: true }));
  }))
);

I've tried adding done() to my upstream tasks, but it still errors because I'm thinking it originates here and propogates through my subsequent tasks that rely on this one finishing.

The problem ended up being the module event-stream . Apparently it is no longer being maintained .

@phated:

Support for event-stream is deprecated. Everything is supposed to move to through2, et al. Maybe just fully deprecate this module?

I switched to merge-stream and now my gulpfile works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM