| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var RawSource = require("webpack-core/lib/RawSource"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function JsonpChunkTemplate(outputOptions) { | 
					
						
							|  |  |  | 	this.outputOptions = outputOptions || {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = JsonpChunkTemplate; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | JsonpChunkTemplate.prototype.render = function(chunk, moduleTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 	var jsonpFunction = this.outputOptions.jsonpFunction || ("webpackJsonp" + (this.outputOptions.library || "")); | 
					
						
							|  |  |  | 	var buf = []; | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 	buf.push(jsonpFunction + "(" + JSON.stringify(chunk.ids) + ", {\n"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	chunk.modules.forEach(function(module, idx) { | 
					
						
							|  |  |  | 		if(idx != 0) buf.push(",\n"); | 
					
						
							|  |  |  | 		buf.push("\n/***/ " + module.id + ":\n"); | 
					
						
							|  |  |  | 		var source = moduleTemplate.render(module, dependencyTemplates); | 
					
						
							|  |  |  | 		buf.push(source.source()); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	buf.push("\n\n})"); | 
					
						
							|  |  |  | 	return new RawSource(buf.join("")); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | JsonpChunkTemplate.prototype.updateHash = function(hash) { | 
					
						
							|  |  |  | 	hash.update("jsonp"); | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 	hash.update("2"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	hash.update(this.outputOptions.jsonpFunction + ""); | 
					
						
							|  |  |  | 	hash.update(this.outputOptions.library + ""); | 
					
						
							|  |  |  | }; |