diff --git a/packages/webpack5/src/bin/index.ts b/packages/webpack5/src/bin/index.ts index 1793c87eb..5fa8b394e 100644 --- a/packages/webpack5/src/bin/index.ts +++ b/packages/webpack5/src/bin/index.ts @@ -150,7 +150,14 @@ program webpackCompilationCallback ); } else { - compiler.run(webpackCompilationCallback); + compiler.run((err, status) => { + compiler.close((err2) => + webpackCompilationCallback( + (err || err2) as webpack.WebpackError, + status + ) + ); + }); } });