| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | var ConcatSource = require("webpack-core/lib/ConcatSource"); | 
					
						
							|  |  |  | var OriginalSource = require("webpack-core/lib/OriginalSource"); | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function UmdMainTemplateDecorator(mainTemplate, name) { | 
					
						
							|  |  |  | 	this.mainTemplate = mainTemplate; | 
					
						
							|  |  |  | 	this.name = name; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = UmdMainTemplateDecorator; | 
					
						
							|  |  |  | UmdMainTemplateDecorator.prototype.render = function(hash, chunk, moduleTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 	var source = this.mainTemplate.render(hash, chunk, moduleTemplate, dependencyTemplates); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | 	return new ConcatSource(new OriginalSource( | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | 		"(function webpackUniversalModuleDefinition(root) {\n" + | 
					
						
							|  |  |  | 		"	return function webpackUniversalModuleDefinitionWrapBootstrap(fn) {\n" + | 
					
						
							|  |  |  | 		"		return function webpackUniversalModuleDefinitionBootstrap(modules) {\n" + | 
					
						
							|  |  |  | 		"			if(typeof exports === 'object' && typeof module === 'object')\n" + | 
					
						
							|  |  |  | 		"				module.exports = fn(modules);\n" + | 
					
						
							|  |  |  | 		"			else if(typeof define === 'function' && define.amd)\n" + | 
					
						
							|  |  |  | 		"				define(function() { return fn(modules); });\n" + | 
					
						
							| 
									
										
										
										
											2013-10-16 04:00:28 +08:00
										 |  |  | 		(this.name ? | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | 		"			else if(typeof exports === 'object')\n" + | 
					
						
							|  |  |  | 		"				exports[" + JSON.stringify(this.name) + "] = fn(modules);\n" + | 
					
						
							|  |  |  | 		"			else\n" + | 
					
						
							| 
									
										
										
										
											2013-10-16 04:00:28 +08:00
										 |  |  | 		"				root[" + JSON.stringify(this.name) + "] = fn(modules);\n" | 
					
						
							|  |  |  | 		: | 
					
						
							|  |  |  | 		"			else {\n" + | 
					
						
							|  |  |  | 		"				var a = fn(modules);\n" + | 
					
						
							|  |  |  | 		"				for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" + | 
					
						
							|  |  |  | 		"			}\n" | 
					
						
							|  |  |  | 		) + | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | 		"		}\n" + | 
					
						
							|  |  |  | 		"	}\n" + | 
					
						
							| 
									
										
										
										
											2014-02-12 15:57:26 +08:00
										 |  |  | 		"})(this)\n", "webpack/universalModuleDefinition"), source); | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | UmdMainTemplateDecorator.prototype.updateHash = function(hash) { | 
					
						
							|  |  |  | 	hash.update("umd"); | 
					
						
							| 
									
										
										
										
											2013-06-28 20:20:11 +08:00
										 |  |  | 	hash.update(this.name + ""); | 
					
						
							| 
									
										
										
										
											2013-03-11 21:51:23 +08:00
										 |  |  | 	this.mainTemplate.updateHash(hash); | 
					
						
							| 
									
										
										
										
											2013-11-29 15:46:54 +08:00
										 |  |  | }; |