File tree 1 file changed +15
-2
lines changed 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -545,8 +545,21 @@ class Compiler {
545
545
*/
546
546
runAsChild ( callback ) {
547
547
const startTime = Date . now ( ) ;
548
+
549
+ const finalCallback = ( err , entries , compilation ) => {
550
+ try {
551
+ callback ( err , entries , compilation ) ;
552
+ } catch ( e ) {
553
+ const err = new WebpackError (
554
+ `compiler.runAsChild callback error: ${ e } `
555
+ ) ;
556
+ err . details = e . stack ;
557
+ this . parentCompilation . errors . push ( err ) ;
558
+ }
559
+ } ;
560
+
548
561
this . compile ( ( err , compilation ) => {
549
- if ( err ) return callback ( err ) ;
562
+ if ( err ) return finalCallback ( err ) ;
550
563
551
564
this . parentCompilation . children . push ( compilation ) ;
552
565
for ( const { name, source, info } of compilation . getAssets ( ) ) {
@@ -561,7 +574,7 @@ class Compiler {
561
574
compilation . startTime = startTime ;
562
575
compilation . endTime = Date . now ( ) ;
563
576
564
- return callback ( null , entries , compilation ) ;
577
+ return finalCallback ( null , entries , compilation ) ;
565
578
} ) ;
566
579
}
567
580
You can’t perform that action at this time.
0 commit comments