File tree 1 file changed +15
-2
lines changed
packages/angular_devkit/build_webpack/src/webpack
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ export function runWebpack(
52
52
53
53
return createWebpack ( { ...config , watch : false } ) . pipe (
54
54
switchMap ( webpackCompiler => new Observable < BuildResult > ( obs => {
55
+ // Webpack 5 has a compiler level close function
56
+ // The close function will crash if caching is disabled
57
+ const compilerClose = webpackCompiler . options . cache !== false
58
+ ? ( webpackCompiler as { close ?( callback : ( ) => void ) : void } ) . close
59
+ : undefined ;
60
+
55
61
const callback = ( err ?: Error , stats ?: webpack . Stats ) => {
56
62
if ( err ) {
57
63
return obs . error ( err ) ;
@@ -71,7 +77,11 @@ export function runWebpack(
71
77
} as unknown as BuildResult ) ;
72
78
73
79
if ( ! config . watch ) {
74
- obs . complete ( ) ;
80
+ if ( compilerClose ) {
81
+ compilerClose ( ( ) => obs . complete ( ) ) ;
82
+ } else {
83
+ obs . complete ( ) ;
84
+ }
75
85
}
76
86
} ;
77
87
@@ -81,7 +91,10 @@ export function runWebpack(
81
91
const watching = webpackCompiler . watch ( watchOptions , callback ) ;
82
92
83
93
// Teardown logic. Close the watcher when unsubscribed from.
84
- return ( ) => watching . close ( ( ) => { } ) ;
94
+ return ( ) => {
95
+ watching . close ( ( ) => { } ) ;
96
+ compilerClose ?.( ( ) => { } ) ;
97
+ } ;
85
98
} else {
86
99
webpackCompiler . run ( callback ) ;
87
100
}
You can’t perform that action at this time.
0 commit comments