shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.4k stars 123 forks source link

Callback in being ignored in the multicompication case #247

Open TokugawaTakeshi opened 1 year ago

TokugawaTakeshi commented 1 year ago

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.