| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const RuntimeGlobals = require("../RuntimeGlobals"); | 
					
						
							|  |  |  | const Template = require("../Template"); | 
					
						
							|  |  |  | const HelperRuntimeModule = require("./HelperRuntimeModule"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MakeNamespaceObjectRuntimeModule extends HelperRuntimeModule { | 
					
						
							|  |  |  | 	constructor() { | 
					
						
							|  |  |  | 		super("make namespace object"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} runtime code | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-11-20 19:05:12 +08:00
										 |  |  | 	generate() { | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 		const { runtimeTemplate } = this.compilation; | 
					
						
							| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | 		const fn = RuntimeGlobals.makeNamespaceObject; | 
					
						
							|  |  |  | 		return Template.asString([ | 
					
						
							|  |  |  | 			"// define __esModule on exports", | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 			`${fn} = ${runtimeTemplate.basicFunction("exports", [ | 
					
						
							| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | 				"if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {", | 
					
						
							|  |  |  | 				Template.indent([ | 
					
						
							|  |  |  | 					"Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });" | 
					
						
							|  |  |  | 				]), | 
					
						
							|  |  |  | 				"}", | 
					
						
							|  |  |  | 				"Object.defineProperty(exports, '__esModule', { value: true });" | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 			])};`
 | 
					
						
							| 
									
										
										
										
											2018-11-20 17:22:10 +08:00
										 |  |  | 		]); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = MakeNamespaceObjectRuntimeModule; |