| 
									
										
										
										
											2016-12-30 16:52:37 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-19 03:44:27 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2016-12-30 16:52:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | /** @typedef {import("./Compiler")} Compiler */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-23 20:03:37 +08:00
										 |  |  | const PLUGIN_NAME = "NoEmitOnErrorsPlugin"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-19 03:44:27 +08:00
										 |  |  | class NoEmitOnErrorsPlugin { | 
					
						
							| 
									
										
										
										
											2018-11-03 04:05:46 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * Apply the plugin | 
					
						
							|  |  |  | 	 * @param {Compiler} compiler the compiler instance | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-01-19 03:44:27 +08:00
										 |  |  | 	apply(compiler) { | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 		compiler.hooks.shouldEmit.tap(PLUGIN_NAME, (compilation) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (compilation.getStats().hasErrors()) return false; | 
					
						
							| 
									
										
										
										
											2016-12-30 16:52:37 +08:00
										 |  |  | 		}); | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 		compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { | 
					
						
							| 
									
										
										
										
											2025-04-23 20:03:37 +08:00
										 |  |  | 			compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (compilation.getStats().hasErrors()) return false; | 
					
						
							| 
									
										
										
										
											2017-01-19 03:44:27 +08:00
										 |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = NoEmitOnErrorsPlugin; |