@@ -39,6 +39,7 @@ const ModuleTemplate = require("./ModuleTemplate");
39
39
const RuntimeGlobals = require ( "./RuntimeGlobals" ) ;
40
40
const RuntimeTemplate = require ( "./RuntimeTemplate" ) ;
41
41
const Stats = require ( "./Stats" ) ;
42
+ const WebpackError = require ( "./WebpackError" ) ;
42
43
const StatsFactory = require ( "./stats/StatsFactory" ) ;
43
44
const StatsPrinter = require ( "./stats/StatsPrinter" ) ;
44
45
const AsyncQueue = require ( "./util/AsyncQueue" ) ;
@@ -1046,15 +1047,19 @@ class Compilation {
1046
1047
dependency === null ||
1047
1048
! dependency . constructor
1048
1049
) {
1049
- throw new Error ( "Parameter 'dependency' must be a Dependency" ) ;
1050
+ return callback (
1051
+ new WebpackError ( "Parameter 'dependency' must be a Dependency" )
1052
+ ) ;
1050
1053
}
1051
1054
const Dep = /** @type {DepConstructor } */ ( dependency . constructor ) ;
1052
1055
const moduleFactory = this . dependencyFactories . get ( Dep ) ;
1053
1056
if ( ! moduleFactory ) {
1054
- throw new Error (
1055
- `No dependency factory available for this dependency type: ${
1056
- dependency . constructor . name
1057
- } `
1057
+ return callback (
1058
+ new WebpackError (
1059
+ `No dependency factory available for this dependency type: ${
1060
+ dependency . constructor . name
1061
+ } `
1062
+ )
1058
1063
) ;
1059
1064
}
1060
1065
@@ -1066,14 +1071,15 @@ class Compilation {
1066
1071
context
1067
1072
} ,
1068
1073
err => {
1069
- if ( this . bail ) {
1074
+ if ( err && this . bail ) {
1075
+ callback ( err ) ;
1070
1076
this . buildQueue . stop ( ) ;
1071
1077
this . rebuildQueue . stop ( ) ;
1072
1078
this . processDependenciesQueue . stop ( ) ;
1073
1079
this . factorizeQueue . stop ( ) ;
1074
- return callback ( err ) ;
1080
+ } else {
1081
+ callback ( ) ;
1075
1082
}
1076
- return callback ( ) ;
1077
1083
}
1078
1084
) ;
1079
1085
}
0 commit comments