| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 16:42:33 +08:00
										 |  |  | const Tapable = require("tapable").Tapable; | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | const SyncWaterfallHook = require("tapable").SyncWaterfallHook; | 
					
						
							|  |  |  | const SyncHook = require("tapable").SyncHook; | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 16:42:33 +08:00
										 |  |  | module.exports = class ChunkTemplate extends Tapable { | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	constructor(outputOptions) { | 
					
						
							| 
									
										
										
										
											2017-12-07 16:42:33 +08:00
										 |  |  | 		super(); | 
					
						
							|  |  |  | 		this.outputOptions = outputOptions || {}; | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 		this.hooks = { | 
					
						
							| 
									
										
										
										
											2018-01-24 16:39:49 +08:00
										 |  |  | 			renderManifest: new SyncWaterfallHook(["result", "options"]), | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 			modules: new SyncWaterfallHook(["source", "chunk", "moduleTemplate", "dependencyTemplates"]), | 
					
						
							|  |  |  | 			render: new SyncWaterfallHook(["source", "chunk", "moduleTemplate", "dependencyTemplates"]), | 
					
						
							|  |  |  | 			renderWithEntry: new SyncWaterfallHook(["source", "chunk"]), | 
					
						
							|  |  |  | 			hash: new SyncHook(["hash"]), | 
					
						
							|  |  |  | 			hashForChunk: new SyncHook(["hash", "chunk"]), | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-05-20 13:39:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 	getRenderManifest(options) { | 
					
						
							|  |  |  | 		const result = []; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 16:39:49 +08:00
										 |  |  | 		this.hooks.renderManifest.call(result, options); | 
					
						
							| 
									
										
										
										
											2017-10-30 20:56:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return result; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	updateHash(hash) { | 
					
						
							|  |  |  | 		hash.update("ChunkTemplate"); | 
					
						
							|  |  |  | 		hash.update("2"); | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 		this.hooks.hash.call(hash); | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-06-25 05:17:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	updateHashForChunk(hash, chunk) { | 
					
						
							|  |  |  | 		this.updateHash(hash); | 
					
						
							| 
									
										
										
										
											2017-11-29 01:43:01 +08:00
										 |  |  | 		this.hooks.hashForChunk.call(hash, chunk); | 
					
						
							| 
									
										
										
										
											2017-01-13 04:38:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-06-25 05:17:12 +08:00
										 |  |  | }; |