mirror of https://github.com/webpack/webpack.git
				
				
				
			catch error in runAsChild callback
This commit is contained in:
		
							parent
							
								
									86a8bd9618
								
							
						
					
					
						commit
						449d1786c2
					
				|  | @ -545,8 +545,21 @@ class Compiler { | ||||||
| 	 */ | 	 */ | ||||||
| 	runAsChild(callback) { | 	runAsChild(callback) { | ||||||
| 		const startTime = Date.now(); | 		const startTime = Date.now(); | ||||||
| 		this.compile((err, compilation) => { | 
 | ||||||
|  | 		const finalCallback = (err, entries, compilation) => { | ||||||
|  | 			try { | ||||||
| 				if (err) return callback(err); | 				if (err) return callback(err); | ||||||
|  | 				callback(null, entries, compilation); | ||||||
|  | 			} catch (e) { | ||||||
|  | 				const err = new WebpackError( | ||||||
|  | 					`compiler.runAsChild callback error: ${e}` | ||||||
|  | 				); | ||||||
|  | 				this.parentCompilation.errors.push(err); | ||||||
|  | 			} | ||||||
|  | 		}; | ||||||
|  | 
 | ||||||
|  | 		this.compile((err, compilation) => { | ||||||
|  | 			if (err) return finalCallback(err); | ||||||
| 
 | 
 | ||||||
| 			this.parentCompilation.children.push(compilation); | 			this.parentCompilation.children.push(compilation); | ||||||
| 			for (const { name, source, info } of compilation.getAssets()) { | 			for (const { name, source, info } of compilation.getAssets()) { | ||||||
|  | @ -561,7 +574,7 @@ class Compiler { | ||||||
| 			compilation.startTime = startTime; | 			compilation.startTime = startTime; | ||||||
| 			compilation.endTime = Date.now(); | 			compilation.endTime = Date.now(); | ||||||
| 
 | 
 | ||||||
| 			return callback(null, entries, compilation); | 			return finalCallback(null, entries, compilation); | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue