Skip to content

Callback in being ignored in the multicompication case #247

@TokugawaTakeshi

Description

@TokugawaTakeshi

The running of gulp build corresponding to below setup

const gulp = require("gulp");
const gulpWebpack = require('webpack-stream');


const webpackConfig = {
  watch: true,
  mode: "production"
};


gulp.task("webpack", function() {
  return gulp.src("Source/EntryPoint.js").
      pipe(
        gulpWebpack(
          { config: webpackConfig },
          null,
          (error, statistics) => {

            if (error) {
              console.error(error);
            }

            if (statistics) {
              process.stdout.write(`${ statistics.toString({ colors: true }) }\n`);
            }

          }
        )
      ).
      pipe(gulp.dest("Output/"));
});


gulp.task("build", gulp.series("webpack"));

causes the following warning:

(node:41540) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.

and the execution stops after first build. If we'll replace the multicompilation with single compilation:

const gulp = require("gulp");
const gulpWebpack = require('webpack-stream');

gulp.task("webpack", function() {
  return gulp.src("Source/EntryPoint.js").
      pipe(
        gulpWebpack(
           {
              watch: true,
              mode: "production"
           },
          null,
          (error, statistics) => {

            if (error) {
              console.error(error);
            }

            if (statistics) {
              process.stdout.write(`${ statistics.toString({ colors: true }) }\n`);
            }

          }
        )
      ).
      pipe(gulp.dest("Output/"));
});

everything will work fine.

If it is the bug, would you please to fix it?
I have pasted the reproduction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions