| 
									
										
										
										
											2017-05-10 19:15:14 +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-05-10 19:15:14 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 07:47:01 +08:00
										 |  |  | const eslintScope = require("eslint-scope"); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | const { | 
					
						
							|  |  |  | 	CachedSource, | 
					
						
							|  |  |  | 	ConcatSource, | 
					
						
							|  |  |  | 	ReplaceSource | 
					
						
							|  |  |  | } = require("webpack-sources"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const DependencyTemplate = require("../DependencyTemplate"); | 
					
						
							|  |  |  | const Module = require("../Module"); | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | const { UsageState } = require("../ModuleGraph"); | 
					
						
							| 
									
										
										
										
											2018-11-05 21:36:15 +08:00
										 |  |  | const RuntimeGlobals = require("../RuntimeGlobals"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const Template = require("../Template"); | 
					
						
							|  |  |  | const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); | 
					
						
							|  |  |  | const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExportExpressionDependency"); | 
					
						
							|  |  |  | const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency"); | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | const HarmonyExportInitFragment = require("../dependencies/HarmonyExportInitFragment"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const HarmonyExportSpecifierDependency = require("../dependencies/HarmonyExportSpecifierDependency"); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency"); | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency"); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency"); | 
					
						
							| 
									
										
										
										
											2019-10-11 21:46:57 +08:00
										 |  |  | const JavascriptParser = require("../javascript/JavascriptParser"); | 
					
						
							| 
									
										
										
										
											2019-08-07 15:54:43 +08:00
										 |  |  | const LazySet = require("../util/LazySet"); | 
					
						
							| 
									
										
										
										
											2019-10-30 05:02:22 +08:00
										 |  |  | const { concatComparators, keepOriginalOrder } = require("../util/comparators"); | 
					
						
							| 
									
										
										
										
											2017-11-23 17:59:29 +08:00
										 |  |  | const createHash = require("../util/createHash"); | 
					
						
							| 
									
										
										
										
											2018-12-07 22:36:49 +08:00
										 |  |  | const contextify = require("../util/identifier").contextify; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | const propertyAccess = require("../util/propertyAccess"); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											2019-11-11 22:25:03 +08:00
										 |  |  | /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | /** @typedef {import("../ChunkGraph")} ChunkGraph */ | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | /** @typedef {import("../Compilation")} Compilation */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("../Dependency")} Dependency */ | 
					
						
							| 
									
										
										
										
											2018-07-18 01:38:42 +08:00
										 |  |  | /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */ | 
					
						
							|  |  |  | /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | /** @typedef {import("../ModuleGraph")} ModuleGraph */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("../RequestShortener")} RequestShortener */ | 
					
						
							| 
									
										
										
										
											2019-11-11 22:25:03 +08:00
										 |  |  | /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | /** @typedef {import("../WebpackError")} WebpackError */ | 
					
						
							| 
									
										
										
										
											2019-07-17 22:02:33 +08:00
										 |  |  | /** @typedef {import("../util/Hash")} Hash */ | 
					
						
							| 
									
										
										
										
											2019-11-11 22:25:03 +08:00
										 |  |  | /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ReexportInfo | 
					
						
							|  |  |  |  * @property {Module} module | 
					
						
							|  |  |  |  * @property {string[]} exportName | 
					
						
							|  |  |  |  * @property {Dependency} dependency | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | /** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo } ModuleInfo */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ConcatenatedModuleInfo | 
					
						
							|  |  |  |  * @property {"concatenated"} type | 
					
						
							|  |  |  |  * @property {Module} module | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @property {number} index | 
					
						
							|  |  |  |  * @property {Object} ast | 
					
						
							|  |  |  |  * @property {Source} internalSource | 
					
						
							|  |  |  |  * @property {ReplaceSource} source | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  |  * @property {Iterable<string>} runtimeRequirements | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  |  * @property {TODO} globalScope | 
					
						
							|  |  |  |  * @property {TODO} moduleScope | 
					
						
							|  |  |  |  * @property {TODO} internalNames | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @property {Map<string | true, string>} exportMap | 
					
						
							|  |  |  |  * @property {Map<string, ReexportInfo>} reexportMap | 
					
						
							|  |  |  |  * @property {boolean} hasNamespaceObject | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  |  * @property {TODO} namespaceObjectSource | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ExternalModuleInfo | 
					
						
							|  |  |  |  * @property {"external"} type | 
					
						
							|  |  |  |  * @property {Module} module | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @property {number} index | 
					
						
							|  |  |  |  * @property {string} name | 
					
						
							|  |  |  |  * @property {boolean} interopNamespaceObjectUsed | 
					
						
							|  |  |  |  * @property {string} interopNamespaceObjectName | 
					
						
							|  |  |  |  * @property {boolean} interopDefaultAccessUsed | 
					
						
							|  |  |  |  * @property {string} interopDefaultAccessName | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 22:02:17 +08:00
										 |  |  | const RESERVED_NAMES = [ | 
					
						
							|  |  |  | 	// internal name
 | 
					
						
							|  |  |  | 	"__WEBPACK_MODULE_DEFAULT_EXPORT__", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// keywords
 | 
					
						
							|  |  |  | 	"abstract,arguments,async,await,boolean,break,byte,case,catch,char,class,const,continue", | 
					
						
							|  |  |  | 	"debugger,default,delete,do,double,else,enum,eval,export,extends,false,final,finally,float", | 
					
						
							|  |  |  | 	"for,function,goto,if,implements,import,in,instanceof,int,interface,let,long,native,new,null", | 
					
						
							|  |  |  | 	"package,private,protected,public,return,short,static,super,switch,synchronized,this,throw", | 
					
						
							|  |  |  | 	"throws,transient,true,try,typeof,var,void,volatile,while,with,yield", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// commonjs
 | 
					
						
							|  |  |  | 	"module,__dirname,__filename,exports", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// js globals
 | 
					
						
							|  |  |  | 	"Array,Date,eval,function,hasOwnProperty,Infinity,isFinite,isNaN,isPrototypeOf,length,Math", | 
					
						
							|  |  |  | 	"NaN,name,Number,Object,prototype,String,toString,undefined,valueOf", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// browser globals
 | 
					
						
							|  |  |  | 	"alert,all,anchor,anchors,area,assign,blur,button,checkbox,clearInterval,clearTimeout", | 
					
						
							|  |  |  | 	"clientInformation,close,closed,confirm,constructor,crypto,decodeURI,decodeURIComponent", | 
					
						
							|  |  |  | 	"defaultStatus,document,element,elements,embed,embeds,encodeURI,encodeURIComponent,escape", | 
					
						
							|  |  |  | 	"event,fileUpload,focus,form,forms,frame,innerHeight,innerWidth,layer,layers,link,location", | 
					
						
							|  |  |  | 	"mimeTypes,navigate,navigator,frames,frameRate,hidden,history,image,images,offscreenBuffering", | 
					
						
							|  |  |  | 	"open,opener,option,outerHeight,outerWidth,packages,pageXOffset,pageYOffset,parent,parseFloat", | 
					
						
							|  |  |  | 	"parseInt,password,pkcs11,plugin,prompt,propertyIsEnum,radio,reset,screenX,screenY,scroll", | 
					
						
							|  |  |  | 	"secure,select,self,setInterval,setTimeout,status,submit,taint,text,textarea,top,unescape", | 
					
						
							|  |  |  | 	"untaint,window", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// window events
 | 
					
						
							|  |  |  | 	"onblur,onclick,onerror,onfocus,onkeydown,onkeypress,onkeyup,onmouseover,onload,onmouseup,onmousedown,onsubmit" | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | 	.join(",") | 
					
						
							|  |  |  | 	.split(","); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-30 05:02:22 +08:00
										 |  |  | const bySourceOrder = (a, b) => { | 
					
						
							|  |  |  | 	const aOrder = a.sourceOrder; | 
					
						
							|  |  |  | 	const bOrder = b.sourceOrder; | 
					
						
							|  |  |  | 	if (isNaN(aOrder)) { | 
					
						
							|  |  |  | 		if (!isNaN(bOrder)) { | 
					
						
							|  |  |  | 			return 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (isNaN(bOrder)) { | 
					
						
							|  |  |  | 			return -1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (aOrder !== bOrder) { | 
					
						
							|  |  |  | 			return aOrder < bOrder ? -1 : 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | const arrayEquals = (a, b) => { | 
					
						
							|  |  |  | 	if (a.length !== b.length) return false; | 
					
						
							|  |  |  | 	for (let i = 0; i < a.length; i++) { | 
					
						
							|  |  |  | 		if (a[i] !== b[i]) return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @typedef {Object} ConcatenationEntry | 
					
						
							|  |  |  |  * @property {"concatenated" | "external"} type | 
					
						
							|  |  |  |  * @property {Module} module | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  |  * @param {ConcatenatedModuleInfo} info module info | 
					
						
							|  |  |  |  * @param {Map<Module, ModuleInfo>} moduleToInfoMap moduleToInfoMap | 
					
						
							|  |  |  |  * @param {RequestShortener} requestShortener requestShortener | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  |  * @param {RuntimeTemplate} runtimeTemplate runtimeTemplate | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @param {boolean} strictHarmonyModule strictHarmonyModule | 
					
						
							|  |  |  |  * @returns {void} | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const ensureNsObjSource = ( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 	moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	info, | 
					
						
							|  |  |  | 	moduleToInfoMap, | 
					
						
							|  |  |  | 	requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 	runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	strictHarmonyModule | 
					
						
							|  |  |  | ) => { | 
					
						
							|  |  |  | 	if (!info.hasNamespaceObject) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		info.hasNamespaceObject = true; | 
					
						
							|  |  |  | 		const name = info.exportMap.get(true); | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 		const nsObj = []; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		const exportsInfo = moduleGraph.getExportsInfo(info.module); | 
					
						
							|  |  |  | 		for (const exportInfo of exportsInfo.orderedExports) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			const finalName = getFinalName( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 				moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				info, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				[exportInfo.name], | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				moduleToInfoMap, | 
					
						
							|  |  |  | 				requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 				runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				false, | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  | 				undefined, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 				strictHarmonyModule, | 
					
						
							|  |  |  | 				true | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			); | 
					
						
							|  |  |  | 			nsObj.push( | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 				`\n  ${JSON.stringify( | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					exportInfo.getUsedName() | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 				)}: ${runtimeTemplate.returningFunction(finalName)}`
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 		info.namespaceObjectSource = `var ${name} = {};\n${ | 
					
						
							|  |  |  | 			RuntimeGlobals.makeNamespaceObject | 
					
						
							|  |  |  | 		}(${name});\n${RuntimeGlobals.definePropertyGetters}(${name}, {${nsObj.join( | 
					
						
							|  |  |  | 			"," | 
					
						
							|  |  |  | 		)}\n});\n`;
 | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  |  * @param {Module} importedModule module | 
					
						
							|  |  |  |  * @param {ExternalModuleInfo} info module info | 
					
						
							|  |  |  |  * @param {string[]} exportName exportName | 
					
						
							|  |  |  |  * @param {boolean} asCall asCall | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  |  * @param {boolean} callContext callContext | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @param {boolean} strictHarmonyModule strictHarmonyModule | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  |  * @param {boolean} asiSafe asiSafe | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @returns {string} expression to get value of external module | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const getExternalImport = ( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 	moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	importedModule, | 
					
						
							|  |  |  | 	info, | 
					
						
							|  |  |  | 	exportName, | 
					
						
							|  |  |  | 	asCall, | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  | 	callContext, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 	strictHarmonyModule, | 
					
						
							|  |  |  | 	asiSafe | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | ) => { | 
					
						
							| 
									
										
										
										
											2019-01-28 17:40:32 +08:00
										 |  |  | 	const used = | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		exportName.length === 0 || | 
					
						
							|  |  |  | 		importedModule.getUsedName(moduleGraph, exportName); | 
					
						
							| 
									
										
										
										
											2019-09-03 20:10:07 +08:00
										 |  |  | 	if (!used) return "/* unused export */undefined"; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 	const comment = arrayEquals(used, exportName) | 
					
						
							|  |  |  | 		? "" | 
					
						
							|  |  |  | 		: Template.toNormalComment(`${exportName.join(".")}`); | 
					
						
							|  |  |  | 	let exprStart; | 
					
						
							|  |  |  | 	if (exportName.length === 0) { | 
					
						
							|  |  |  | 		switch (importedModule.buildMeta.exportsType) { | 
					
						
							|  |  |  | 			case "named": | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 				info.interopNamespaceObjectUsed = true; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				exprStart = info.interopNamespaceObjectName; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			case "namespace": | 
					
						
							|  |  |  | 				exprStart = info.name; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			default: | 
					
						
							|  |  |  | 				if (strictHarmonyModule) { | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 					info.interopNamespaceObjectUsed = true; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					exprStart = info.interopNamespaceObjectName; | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					exprStart = info.name; | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		switch (importedModule.buildMeta.exportsType) { | 
					
						
							|  |  |  | 			case "named": | 
					
						
							| 
									
										
										
										
											2019-08-21 21:08:07 +08:00
										 |  |  | 			case "namespace": | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			default: | 
					
						
							|  |  |  | 				if (strictHarmonyModule) { | 
					
						
							|  |  |  | 					if (exportName[0] === "default") { | 
					
						
							|  |  |  | 						exprStart = info.name; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						exprStart = "/* non-default import from non-esm module */undefined"; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					if (exportName[0] === "default") { | 
					
						
							|  |  |  | 						info.interopDefaultAccessUsed = true; | 
					
						
							|  |  |  | 						exprStart = asCall | 
					
						
							|  |  |  | 							? `${info.interopDefaultAccessName}()` | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 							: asiSafe | 
					
						
							|  |  |  | 							? `(${info.interopDefaultAccessName}())` | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 							: `${info.interopDefaultAccessName}.a`; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (exprStart) { | 
					
						
							| 
									
										
										
										
											2019-08-21 21:08:07 +08:00
										 |  |  | 		return `${exprStart}${propertyAccess(used, 1)}`; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 	const reference = `${info.name}${comment}${propertyAccess(used)}`; | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 	if (asCall && callContext === false) { | 
					
						
							|  |  |  | 		return asiSafe ? `(0,${reference})` : `Object(${reference})`; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return reference; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  |  * @param {ModuleInfo} info module info | 
					
						
							|  |  |  |  * @param {string[]} exportName exportName | 
					
						
							|  |  |  |  * @param {Map<Module, ModuleInfo>} moduleToInfoMap moduleToInfoMap | 
					
						
							|  |  |  |  * @param {RequestShortener} requestShortener the request shortener | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  |  * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @param {boolean} asCall asCall | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  |  * @param {boolean} callContext callContext | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @param {boolean} strictHarmonyModule strictHarmonyModule | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  |  * @param {boolean} asiSafe asiSafe | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  |  * @param {Set<ReexportInfo>} alreadyVisited alreadyVisited | 
					
						
							|  |  |  |  * @returns {string} the final name | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const getFinalName = ( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 	moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	info, | 
					
						
							|  |  |  | 	exportName, | 
					
						
							|  |  |  | 	moduleToInfoMap, | 
					
						
							|  |  |  | 	requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 	runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	asCall, | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  | 	callContext, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 	strictHarmonyModule, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 	asiSafe, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 	alreadyVisited = new Set() | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | ) => { | 
					
						
							|  |  |  | 	switch (info.type) { | 
					
						
							|  |  |  | 		case "concatenated": { | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			if (exportName.length === 0) { | 
					
						
							|  |  |  | 				ensureNsObjSource( | 
					
						
							|  |  |  | 					moduleGraph, | 
					
						
							|  |  |  | 					info, | 
					
						
							|  |  |  | 					moduleToInfoMap, | 
					
						
							|  |  |  | 					requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 					runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					strictHarmonyModule | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				return info.internalNames.get(info.exportMap.get(true)); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			const exportId = exportName[0]; | 
					
						
							|  |  |  | 			const directExport = info.exportMap.get(exportId); | 
					
						
							|  |  |  | 			const exportsInfo = moduleGraph.getExportsInfo(info.module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (directExport) { | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				if (exportsInfo.isExportUsed(exportName) === UsageState.Unused) { | 
					
						
							|  |  |  | 					return `/* unused export */ undefined${propertyAccess( | 
					
						
							|  |  |  | 						exportName, | 
					
						
							|  |  |  | 						1 | 
					
						
							|  |  |  | 					)}`;
 | 
					
						
							| 
									
										
										
										
											2018-08-20 16:34:58 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const name = info.internalNames.get(directExport); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				if (!name) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						`The export "${directExport}" in "${info.module.readableIdentifier( | 
					
						
							|  |  |  | 							requestShortener | 
					
						
							|  |  |  | 						)}" has no internal name`
 | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				return `${name}${propertyAccess(exportName, 1)}`; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			const reexport = info.reexportMap.get(exportId); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (reexport) { | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 				if (alreadyVisited.has(reexport)) { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						`Circular reexports ${Array.from( | 
					
						
							|  |  |  | 							alreadyVisited, | 
					
						
							|  |  |  | 							e => | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 								`"${e.module.readableIdentifier( | 
					
						
							|  |  |  | 									requestShortener | 
					
						
							|  |  |  | 								)}".${e.exportName.join(".")}`
 | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 						).join( | 
					
						
							|  |  |  | 							" --> " | 
					
						
							|  |  |  | 						)} -(circular)-> "${reexport.module.readableIdentifier( | 
					
						
							|  |  |  | 							requestShortener | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 						)}".${reexport.exportName.join(".")}`
 | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				alreadyVisited.add(reexport); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const refInfo = moduleToInfoMap.get(reexport.module); | 
					
						
							|  |  |  | 				if (refInfo) { | 
					
						
							|  |  |  | 					// module is in the concatenation
 | 
					
						
							|  |  |  | 					return getFinalName( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 						moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						refInfo, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 						[...reexport.exportName, ...exportName.slice(1)], | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						moduleToInfoMap, | 
					
						
							|  |  |  | 						requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 						runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						asCall, | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  | 						callContext, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 						strictHarmonyModule, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 						asiSafe, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 						alreadyVisited | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			const problem = | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 				`Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier( | 
					
						
							|  |  |  | 					requestShortener | 
					
						
							|  |  |  | 				)}"` +
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				` (known exports: ${Array.from(info.exportMap.keys()) | 
					
						
							|  |  |  | 					.filter(name => name !== true) | 
					
						
							|  |  |  | 					.join(" ")}, ` +
 | 
					
						
							|  |  |  | 				`known reexports: ${Array.from(info.reexportMap.keys()).join(" ")})`; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 			return `${Template.toNormalComment(problem)} undefined${propertyAccess( | 
					
						
							|  |  |  | 				exportName, | 
					
						
							|  |  |  | 				1 | 
					
						
							|  |  |  | 			)}`;
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		case "external": { | 
					
						
							|  |  |  | 			const importedModule = info.module; | 
					
						
							|  |  |  | 			return getExternalImport( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 				moduleGraph, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				importedModule, | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				exportName, | 
					
						
							|  |  |  | 				asCall, | 
					
						
							| 
									
										
										
										
											2019-07-31 22:01:35 +08:00
										 |  |  | 				callContext, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 				strictHarmonyModule, | 
					
						
							|  |  |  | 				asiSafe | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | const addScopeSymbols1 = (s, nameSet, scopeSet) => { | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 	let scope = s; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	while (scope) { | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 		if (scopeSet.has(scope)) break; | 
					
						
							|  |  |  | 		scopeSet.add(scope); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const variable of scope.variables) { | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 			nameSet.add(variable.name); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		scope = scope.upper; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const addScopeSymbols2 = (s, nameSet, scopeSet1, scopeSet2) => { | 
					
						
							|  |  |  | 	let scope = s; | 
					
						
							|  |  |  | 	while (scope) { | 
					
						
							|  |  |  | 		if (scopeSet1.has(scope)) break; | 
					
						
							|  |  |  | 		if (scopeSet2.has(scope)) break; | 
					
						
							|  |  |  | 		scopeSet1.add(scope); | 
					
						
							|  |  |  | 		for (const variable of scope.variables) { | 
					
						
							|  |  |  | 			nameSet.add(variable.name); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 		scope = scope.upper; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | const getAllReferences = variable => { | 
					
						
							| 
									
										
										
										
											2017-06-06 17:18:34 +08:00
										 |  |  | 	let set = variable.references; | 
					
						
							|  |  |  | 	// Look for inner scope variables too (like in class Foo { t() { Foo } })
 | 
					
						
							|  |  |  | 	const identifiers = new Set(variable.identifiers); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	for (const scope of variable.scope.childScopes) { | 
					
						
							|  |  |  | 		for (const innerVar of scope.variables) { | 
					
						
							|  |  |  | 			if (innerVar.identifiers.some(id => identifiers.has(id))) { | 
					
						
							| 
									
										
										
										
											2017-06-06 17:18:34 +08:00
										 |  |  | 				set = set.concat(innerVar.references); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return set; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-06-06 17:18:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | const getPathInAst = (ast, node) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (ast === node) { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 		return []; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 	const nr = node.range; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	const enterNode = n => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!n) return undefined; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		const r = n.range; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (r) { | 
					
						
							|  |  |  | 			if (r[0] <= nr[0] && r[1] >= nr[1]) { | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 				const path = getPathInAst(n, node); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (path) { | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 					path.push(n); | 
					
						
							|  |  |  | 					return path; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return undefined; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (Array.isArray(ast)) { | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 		for (let i = 0; i < ast.length; i++) { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 			const enterResult = enterNode(ast[i]); | 
					
						
							| 
									
										
										
										
											2018-08-21 08:26:50 +08:00
										 |  |  | 			if (enterResult !== undefined) return enterResult; | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	} else if (ast && typeof ast === "object") { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 		const keys = Object.keys(ast); | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 		for (let i = 0; i < keys.length; i++) { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 			const value = ast[keys[i]]; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (Array.isArray(value)) { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 				const pathResult = getPathInAst(value, node); | 
					
						
							| 
									
										
										
										
											2018-08-21 08:26:50 +08:00
										 |  |  | 				if (pathResult !== undefined) return pathResult; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			} else if (value && typeof value === "object") { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 				const enterResult = enterNode(value); | 
					
						
							| 
									
										
										
										
											2018-08-21 08:26:50 +08:00
										 |  |  | 				if (enterResult !== undefined) return enterResult; | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | const modulesWithInfoToMap = modulesWithInfo => { | 
					
						
							|  |  |  | 	const moduleToInfoMap = new Map(); | 
					
						
							|  |  |  | 	for (const m of modulesWithInfo) { | 
					
						
							|  |  |  | 		moduleToInfoMap.set(m.module, m); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return moduleToInfoMap; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | const createModuleReference = ({ | 
					
						
							|  |  |  | 	info, | 
					
						
							|  |  |  | 	ids = undefined, | 
					
						
							|  |  |  | 	call = false, | 
					
						
							|  |  |  | 	directImport = false, | 
					
						
							|  |  |  | 	strict = false, | 
					
						
							|  |  |  | 	asiSafe = false | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  | 	const callFlag = call ? "_call" : ""; | 
					
						
							|  |  |  | 	const directImportFlag = directImport ? "_directImport" : ""; | 
					
						
							|  |  |  | 	const strictFlag = strict ? "_strict" : ""; | 
					
						
							|  |  |  | 	const asiSafeFlag = asiSafe ? "_asiSafe" : ""; | 
					
						
							|  |  |  | 	const exportData = ids | 
					
						
							|  |  |  | 		? Buffer.from(JSON.stringify(ids), "utf-8").toString("hex") | 
					
						
							|  |  |  | 		: "ns"; | 
					
						
							|  |  |  | 	return `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${directImportFlag}${strictFlag}${asiSafeFlag}__`; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const MODULE_REFERENCE_REGEXP = /^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_directImport)?(_strict)?(_asiSafe)?__$/; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const isModuleReference = name => { | 
					
						
							|  |  |  | 	return MODULE_REFERENCE_REGEXP.test(name); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const matchModuleReference = (name, modulesWithInfo) => { | 
					
						
							|  |  |  | 	const match = MODULE_REFERENCE_REGEXP.exec(name); | 
					
						
							|  |  |  | 	if (!match) return null; | 
					
						
							|  |  |  | 	return { | 
					
						
							|  |  |  | 		info: modulesWithInfo[+match[1]], | 
					
						
							|  |  |  | 		ids: | 
					
						
							|  |  |  | 			match[2] === "ns" | 
					
						
							|  |  |  | 				? [] | 
					
						
							|  |  |  | 				: JSON.parse(Buffer.from(match[2], "hex").toString("utf-8")), | 
					
						
							|  |  |  | 		call: !!match[3], | 
					
						
							|  |  |  | 		directImport: !!match[4], | 
					
						
							|  |  |  | 		strict: !!match[5], | 
					
						
							|  |  |  | 		asiSafe: !!match[6] | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | const TYPES = new Set(["javascript"]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | class ConcatenatedModule extends Module { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Module} rootModule the root module of the concatenation | 
					
						
							|  |  |  | 	 * @param {Set<Module>} modules all modules in the concantenation (including the root module) | 
					
						
							|  |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	constructor(rootModule, modules, compilation) { | 
					
						
							| 
									
										
										
										
											2018-01-31 04:40:44 +08:00
										 |  |  | 		super("javascript/esm", null); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Factory
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.rootModule = rootModule; | 
					
						
							| 
									
										
										
										
											2018-06-26 21:27:44 +08:00
										 |  |  | 		this.factoryMeta = rootModule.factoryMeta; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 		const modulesArray = Array.from(modules); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		// Info from Build
 | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.buildInfo = { | 
					
						
							|  |  |  | 			strict: true, | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 			cacheable: modulesArray.every(m => m.buildInfo.cacheable), | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 			moduleArgument: rootModule.buildInfo.moduleArgument, | 
					
						
							|  |  |  | 			exportsArgument: rootModule.buildInfo.exportsArgument, | 
					
						
							| 
									
										
										
										
											2019-08-07 15:54:43 +08:00
										 |  |  | 			fileDependencies: new LazySet(), | 
					
						
							|  |  |  | 			contextDependencies: new LazySet(), | 
					
						
							|  |  |  | 			missingDependencies: new LazySet(), | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 			assets: undefined | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 		this.buildMeta = rootModule.buildMeta; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Caching
 | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 		this._numberOfConcatenatedModules = modules.size; | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		// Graph
 | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 		this.dependencies = []; | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 		this._orderedConcatenationList = ConcatenatedModule._createConcatenationList( | 
					
						
							|  |  |  | 			rootModule, | 
					
						
							| 
									
										
										
										
											2018-12-30 20:45:45 +08:00
										 |  |  | 			modules, | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 			compilation | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of this._orderedConcatenationList) { | 
					
						
							|  |  |  | 			if (info.type === "concatenated") { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				const m = info.module; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// populate dependencies
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				for (const d of m.dependencies.filter( | 
					
						
							|  |  |  | 					dep => | 
					
						
							|  |  |  | 						!(dep instanceof HarmonyImportDependency) || | 
					
						
							| 
									
										
										
										
											2018-12-30 20:45:45 +08:00
										 |  |  | 						!modules.has(compilation.moduleGraph.getModule(dep)) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				)) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 					this.dependencies.push(d); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-11-08 22:39:44 +08:00
										 |  |  | 				if (m.presentationalDependencies !== undefined) { | 
					
						
							|  |  |  | 					for (const d of m.presentationalDependencies.filter( | 
					
						
							|  |  |  | 						dep => | 
					
						
							|  |  |  | 							!(dep instanceof HarmonyImportDependency) || | 
					
						
							|  |  |  | 							!modules.has(compilation.moduleGraph.getModule(dep)) | 
					
						
							|  |  |  | 					)) { | 
					
						
							|  |  |  | 						this.addPresentationalDependency(d); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2019-10-30 13:40:40 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate file dependencies
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (m.buildInfo.fileDependencies) { | 
					
						
							| 
									
										
										
										
											2019-08-07 15:54:43 +08:00
										 |  |  | 					this.buildInfo.fileDependencies.addAll(m.buildInfo.fileDependencies); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate context dependencies
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (m.buildInfo.contextDependencies) { | 
					
						
							| 
									
										
										
										
											2019-08-07 15:54:43 +08:00
										 |  |  | 					this.buildInfo.contextDependencies.addAll( | 
					
						
							|  |  |  | 						m.buildInfo.contextDependencies | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				// populate missing dependencies
 | 
					
						
							|  |  |  | 				if (m.buildInfo.missingDependencies) { | 
					
						
							|  |  |  | 					this.buildInfo.missingDependencies.addAll( | 
					
						
							|  |  |  | 						m.buildInfo.missingDependencies | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate warnings
 | 
					
						
							| 
									
										
										
										
											2019-11-08 19:43:05 +08:00
										 |  |  | 				const warnings = m.getWarnings(); | 
					
						
							|  |  |  | 				if (warnings !== undefined) { | 
					
						
							|  |  |  | 					for (const warning of warnings) { | 
					
						
							|  |  |  | 						this.addWarning(warning); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate errors
 | 
					
						
							| 
									
										
										
										
											2019-11-08 19:43:05 +08:00
										 |  |  | 				const errors = m.getErrors(); | 
					
						
							|  |  |  | 				if (errors !== undefined) { | 
					
						
							|  |  |  | 					for (const error of errors) { | 
					
						
							|  |  |  | 						this.addError(error); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (m.buildInfo.assets) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 					if (this.buildInfo.assets === undefined) { | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 						this.buildInfo.assets = Object.create(null); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 					Object.assign(this.buildInfo.assets, m.buildInfo.assets); | 
					
						
							| 
									
										
										
										
											2017-11-06 23:41:26 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-09-11 17:13:46 +08:00
										 |  |  | 				if (m.buildInfo.assetsInfo) { | 
					
						
							|  |  |  | 					if (this.buildInfo.assetsInfo === undefined) { | 
					
						
							|  |  |  | 						this.buildInfo.assetsInfo = new Map(); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					for (const [key, value] of m.buildInfo.assetsInfo) { | 
					
						
							|  |  |  | 						this.buildInfo.assetsInfo.set(key, value); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-01-19 19:40:00 +08:00
										 |  |  | 		this._identifier = this._createIdentifier(compilation.compiler.root); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-26 21:51:40 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {Set<string>} types availiable (do not mutate) | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	getSourceTypes() { | 
					
						
							|  |  |  | 		return TYPES; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-10 05:23:40 +08:00
										 |  |  | 	get modules() { | 
					
						
							| 
									
										
										
										
											2017-08-12 06:01:50 +08:00
										 |  |  | 		return this._orderedConcatenationList | 
					
						
							|  |  |  | 			.filter(info => info.type === "concatenated") | 
					
						
							|  |  |  | 			.map(info => info.module); | 
					
						
							| 
									
										
										
										
											2017-08-10 05:23:40 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string} a unique identifier of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	identifier() { | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 		return this._identifier; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {RequestShortener} requestShortener the request shortener | 
					
						
							|  |  |  | 	 * @returns {string} a user readable identifier of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	readableIdentifier(requestShortener) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return ( | 
					
						
							|  |  |  | 			this.rootModule.readableIdentifier(requestShortener) + | 
					
						
							|  |  |  | 			` + ${this._numberOfConcatenatedModules - 1} modules` | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 22:24:35 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {LibIdentOptions} options options | 
					
						
							|  |  |  | 	 * @returns {string | null} an identifier for library inclusion | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	libIdent(options) { | 
					
						
							| 
									
										
										
										
											2017-06-05 20:01:19 +08:00
										 |  |  | 		return this.rootModule.libIdent(options); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {string | null} absolute path which should be used for condition matching (usually the resource path) | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	nameForCondition() { | 
					
						
							|  |  |  | 		return this.rootModule.nameForCondition(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2019-11-11 22:25:03 +08:00
										 |  |  | 	 * @param {WebpackOptions} options webpack options | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							| 
									
										
										
										
											2019-11-11 22:25:03 +08:00
										 |  |  | 	 * @param {ResolverWithOptions} resolver the resolver | 
					
						
							|  |  |  | 	 * @param {InputFileSystem} fs the file system | 
					
						
							| 
									
										
										
										
											2018-09-12 00:47:55 +08:00
										 |  |  | 	 * @param {function(WebpackError=): void} callback callback function | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	build(options, compilation, resolver, fs, callback) { | 
					
						
							|  |  |  | 		throw new Error("Cannot build this module. It should be already built."); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-12-04 18:23:40 +08:00
										 |  |  | 	 * @param {string=} type the source type for which the size should be estimated | 
					
						
							| 
									
										
										
										
											2019-05-13 18:29:29 +08:00
										 |  |  | 	 * @returns {number} the estimated size of the module (must be non-zero) | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-12-04 18:23:40 +08:00
										 |  |  | 	size(type) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		// Guess size from embedded modules
 | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		return this._orderedConcatenationList.reduce((sum, info) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			switch (info.type) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				case "concatenated": | 
					
						
							| 
									
										
										
										
											2018-12-04 18:23:40 +08:00
										 |  |  | 					return sum + info.module.size(type); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				case "external": | 
					
						
							|  |  |  | 					return sum + 5; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return sum; | 
					
						
							|  |  |  | 		}, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	 * @private | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 	 * @param {Module} rootModule the root of the concatenation | 
					
						
							|  |  |  | 	 * @param {Set<Module>} modulesSet a set of modules which should be concatenated | 
					
						
							|  |  |  | 	 * @param {Compilation} compilation the compilation context | 
					
						
							|  |  |  | 	 * @returns {ConcatenationEntry[]} concatenation list | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	static _createConcatenationList(rootModule, modulesSet, compilation) { | 
					
						
							| 
									
										
										
										
											2019-10-30 04:37:59 +08:00
										 |  |  | 		const { moduleGraph } = compilation; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		const list = []; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 		const set = new Set(); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | 		/** | 
					
						
							|  |  |  | 		 * @param {Module} module a module | 
					
						
							|  |  |  | 		 * @returns {(function(): Module)[]} imported modules in order | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		const getConcatenatedImports = module => { | 
					
						
							| 
									
										
										
										
											2019-11-08 05:12:31 +08:00
										 |  |  | 			const references = Array.from(moduleGraph.getOutgoingConnections(module)) | 
					
						
							| 
									
										
										
										
											2019-10-30 05:02:22 +08:00
										 |  |  | 				.filter(connection => { | 
					
						
							|  |  |  | 					if (!(connection.dependency instanceof HarmonyImportDependency)) | 
					
						
							|  |  |  | 						return false; | 
					
						
							| 
									
										
										
										
											2019-10-30 04:37:59 +08:00
										 |  |  | 					return connection && connection.module && connection.active; | 
					
						
							|  |  |  | 				}) | 
					
						
							| 
									
										
										
										
											2019-10-30 05:02:22 +08:00
										 |  |  | 				.map(connection => ({ | 
					
						
							|  |  |  | 					connection, | 
					
						
							|  |  |  | 					sourceOrder: | 
					
						
							|  |  |  | 						/** @type {HarmonyImportDependency} */ (connection.dependency) | 
					
						
							|  |  |  | 							.sourceOrder | 
					
						
							|  |  |  | 				})); | 
					
						
							|  |  |  | 			references.sort( | 
					
						
							|  |  |  | 				concatComparators(bySourceOrder, keepOriginalOrder(references)) | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			return references.map(({ connection }) => { | 
					
						
							|  |  |  | 				return () => connection.module; | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		const enterModule = getModule => { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:56:50 +08:00
										 |  |  | 			const module = getModule(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (!module) return; | 
					
						
							|  |  |  | 			if (set.has(module)) return; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 			set.add(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (modulesSet.has(module)) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				const imports = getConcatenatedImports(module); | 
					
						
							|  |  |  | 				imports.forEach(enterModule); | 
					
						
							|  |  |  | 				list.push({ | 
					
						
							|  |  |  | 					type: "concatenated", | 
					
						
							|  |  |  | 					module | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				list.push({ | 
					
						
							|  |  |  | 					type: "external", | 
					
						
							| 
									
										
										
										
											2017-08-07 19:56:50 +08:00
										 |  |  | 					get module() { | 
					
						
							|  |  |  | 						// We need to use a getter here, because the module in the dependency
 | 
					
						
							|  |  |  | 						// could be replaced by some other process (i. e. also replaced with a
 | 
					
						
							|  |  |  | 						// concatenated module)
 | 
					
						
							|  |  |  | 						return getModule(); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				}); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 19:56:50 +08:00
										 |  |  | 		enterModule(() => rootModule); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return list; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-19 19:40:00 +08:00
										 |  |  | 	_createIdentifier(associatedObjectForCache) { | 
					
						
							| 
									
										
										
										
											2017-11-23 23:57:07 +08:00
										 |  |  | 		let orderedConcatenationListIdentifiers = ""; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (let i = 0; i < this._orderedConcatenationList.length; i++) { | 
					
						
							|  |  |  | 			if (this._orderedConcatenationList[i].type === "concatenated") { | 
					
						
							| 
									
										
										
										
											2018-12-07 22:36:49 +08:00
										 |  |  | 				orderedConcatenationListIdentifiers += contextify( | 
					
						
							|  |  |  | 					this.rootModule.context, | 
					
						
							| 
									
										
										
										
											2019-01-19 19:40:00 +08:00
										 |  |  | 					this._orderedConcatenationList[i].module.identifier(), | 
					
						
							|  |  |  | 					associatedObjectForCache | 
					
						
							| 
									
										
										
										
											2018-12-07 22:36:49 +08:00
										 |  |  | 				); | 
					
						
							| 
									
										
										
										
											2017-11-23 23:57:07 +08:00
										 |  |  | 				orderedConcatenationListIdentifiers += " "; | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-23 23:57:07 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-22 18:27:11 +08:00
										 |  |  | 		const hash = createHash("md4"); | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 		hash.update(orderedConcatenationListIdentifiers); | 
					
						
							| 
									
										
										
										
											2018-12-08 01:12:04 +08:00
										 |  |  | 		return this.rootModule.identifier() + "|" + hash.digest("hex"); | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 	 * @param {CodeGenerationContext} context context for code generation | 
					
						
							|  |  |  | 	 * @returns {CodeGenerationResult} result | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 	codeGeneration({ | 
					
						
							|  |  |  | 		dependencyTemplates, | 
					
						
							|  |  |  | 		runtimeTemplate, | 
					
						
							|  |  |  | 		moduleGraph, | 
					
						
							|  |  |  | 		chunkGraph | 
					
						
							|  |  |  | 	}) { | 
					
						
							|  |  |  | 		/** @type {Set<string>} */ | 
					
						
							| 
									
										
										
										
											2019-10-09 17:49:48 +08:00
										 |  |  | 		const runtimeRequirements = new Set(); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 17:31:00 +08:00
										 |  |  | 		const requestShortener = runtimeTemplate.requestShortener; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		// Metainfo for each module
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		const modulesWithInfo = this._getModulesWithInfo(moduleGraph); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Create mapping from module to info
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		const moduleToInfoMap = modulesWithInfoToMap(modulesWithInfo); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Configure template decorators for dependencies
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 		const innerDependencyTemplates = this._getInnerDependencyTemplates( | 
					
						
							|  |  |  | 			dependencyTemplates, | 
					
						
							|  |  |  | 			moduleToInfoMap | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-04-29 04:32:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		// Generate source code and analyse scopes
 | 
					
						
							|  |  |  | 		// Prepare a ReplaceSource for the final source
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			this._analyseModule( | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				innerDependencyTemplates, | 
					
						
							|  |  |  | 				runtimeTemplate, | 
					
						
							|  |  |  | 				moduleGraph, | 
					
						
							|  |  |  | 				chunkGraph | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// List of all used names to avoid conflicts
 | 
					
						
							| 
									
										
										
										
											2018-11-16 22:02:17 +08:00
										 |  |  | 		const allUsedNames = new Set(RESERVED_NAMES); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 		// Set of already checked scopes
 | 
					
						
							|  |  |  | 		const alreadyCheckedScopes = new Set(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		// get all global names
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			if (info.type === "concatenated") { | 
					
						
							|  |  |  | 				const superClassExpressions = []; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// ignore symbols from moduleScope
 | 
					
						
							|  |  |  | 				if (info.moduleScope) { | 
					
						
							|  |  |  | 					alreadyCheckedScopes.add(info.moduleScope); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// The super class expression in class scopes behaves weird
 | 
					
						
							|  |  |  | 					// We store ranges of all super class expressions to make
 | 
					
						
							|  |  |  | 					// renaming to work correctly
 | 
					
						
							|  |  |  | 					for (const childScope of info.moduleScope.childScopes) { | 
					
						
							|  |  |  | 						if (childScope.type !== "class") continue; | 
					
						
							|  |  |  | 						if (!childScope.block.superClass) continue; | 
					
						
							|  |  |  | 						superClassExpressions.push({ | 
					
						
							|  |  |  | 							range: childScope.block.superClass.range, | 
					
						
							|  |  |  | 							variables: childScope.variables | 
					
						
							|  |  |  | 						}); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 				// add global symbols
 | 
					
						
							|  |  |  | 				if (info.globalScope) { | 
					
						
							|  |  |  | 					for (const reference of info.globalScope.through) { | 
					
						
							|  |  |  | 						const name = reference.identifier.name; | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 						if (isModuleReference(name)) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 							for (const expr of superClassExpressions) { | 
					
						
							|  |  |  | 								if ( | 
					
						
							|  |  |  | 									expr.range[0] <= reference.identifier.range[0] && | 
					
						
							|  |  |  | 									expr.range[1] >= reference.identifier.range[1] | 
					
						
							|  |  |  | 								) { | 
					
						
							|  |  |  | 									for (const variable of expr.variables) { | 
					
						
							|  |  |  | 										allUsedNames.add(variable.name); | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 							addScopeSymbols1( | 
					
						
							|  |  |  | 								reference.from, | 
					
						
							|  |  |  | 								allUsedNames, | 
					
						
							|  |  |  | 								alreadyCheckedScopes | 
					
						
							|  |  |  | 							); | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							allUsedNames.add(name); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-08-20 16:34:58 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 		// generate names for symbols
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							|  |  |  | 			switch (info.type) { | 
					
						
							|  |  |  | 				case "concatenated": { | 
					
						
							|  |  |  | 					const namespaceObjectName = this.findNewName( | 
					
						
							|  |  |  | 						"namespaceObject", | 
					
						
							|  |  |  | 						allUsedNames, | 
					
						
							|  |  |  | 						null, | 
					
						
							|  |  |  | 						info.module.readableIdentifier(requestShortener) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					allUsedNames.add(namespaceObjectName); | 
					
						
							|  |  |  | 					info.internalNames.set(namespaceObjectName, namespaceObjectName); | 
					
						
							|  |  |  | 					info.exportMap.set(true, namespaceObjectName); | 
					
						
							|  |  |  | 					for (const variable of info.moduleScope.variables) { | 
					
						
							|  |  |  | 						const name = variable.name; | 
					
						
							|  |  |  | 						if (allUsedNames.has(name)) { | 
					
						
							|  |  |  | 							const references = getAllReferences(variable); | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 							const symbolsInReferences = new Set(); | 
					
						
							|  |  |  | 							const alreadyCheckedInnerScopes = new Set(); | 
					
						
							|  |  |  | 							for (const ref of references) { | 
					
						
							|  |  |  | 								addScopeSymbols2( | 
					
						
							|  |  |  | 									ref.from, | 
					
						
							|  |  |  | 									symbolsInReferences, | 
					
						
							|  |  |  | 									alreadyCheckedInnerScopes, | 
					
						
							|  |  |  | 									alreadyCheckedScopes | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							const newName = this.findNewName( | 
					
						
							|  |  |  | 								name, | 
					
						
							|  |  |  | 								allUsedNames, | 
					
						
							|  |  |  | 								symbolsInReferences, | 
					
						
							|  |  |  | 								info.module.readableIdentifier(requestShortener) | 
					
						
							|  |  |  | 							); | 
					
						
							|  |  |  | 							allUsedNames.add(newName); | 
					
						
							|  |  |  | 							info.internalNames.set(name, newName); | 
					
						
							|  |  |  | 							const source = info.source; | 
					
						
							|  |  |  | 							const allIdentifiers = new Set( | 
					
						
							|  |  |  | 								references.map(r => r.identifier).concat(variable.identifiers) | 
					
						
							|  |  |  | 							); | 
					
						
							|  |  |  | 							for (const identifier of allIdentifiers) { | 
					
						
							|  |  |  | 								const r = identifier.range; | 
					
						
							|  |  |  | 								const path = getPathInAst(info.ast, identifier); | 
					
						
							|  |  |  | 								if ( | 
					
						
							|  |  |  | 									path && | 
					
						
							|  |  |  | 									path.length > 1 && | 
					
						
							|  |  |  | 									path[1].type === "Property" && | 
					
						
							|  |  |  | 									path[1].shorthand | 
					
						
							|  |  |  | 								) { | 
					
						
							|  |  |  | 									source.insert(r[1], `: ${newName}`); | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									source.replace(r[0], r[1] - 1, newName); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} else { | 
					
						
							|  |  |  | 							allUsedNames.add(name); | 
					
						
							|  |  |  | 							info.internalNames.set(name, name); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				case "external": { | 
					
						
							|  |  |  | 					const externalName = this.findNewName( | 
					
						
							|  |  |  | 						"", | 
					
						
							|  |  |  | 						allUsedNames, | 
					
						
							|  |  |  | 						null, | 
					
						
							|  |  |  | 						info.module.readableIdentifier(requestShortener) | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					allUsedNames.add(externalName); | 
					
						
							|  |  |  | 					info.name = externalName; | 
					
						
							|  |  |  | 					if ( | 
					
						
							|  |  |  | 						info.module.buildMeta.exportsType === "named" || | 
					
						
							|  |  |  | 						!info.module.buildMeta.exportsType | 
					
						
							|  |  |  | 					) { | 
					
						
							|  |  |  | 						const externalNameInterop = this.findNewName( | 
					
						
							|  |  |  | 							"namespaceObject", | 
					
						
							|  |  |  | 							allUsedNames, | 
					
						
							|  |  |  | 							null, | 
					
						
							|  |  |  | 							info.module.readableIdentifier(requestShortener) | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						allUsedNames.add(externalNameInterop); | 
					
						
							|  |  |  | 						info.interopNamespaceObjectName = externalNameInterop; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					if (!info.module.buildMeta.exportsType) { | 
					
						
							|  |  |  | 						const externalNameInterop = this.findNewName( | 
					
						
							|  |  |  | 							"default", | 
					
						
							|  |  |  | 							allUsedNames, | 
					
						
							|  |  |  | 							null, | 
					
						
							|  |  |  | 							info.module.readableIdentifier(requestShortener) | 
					
						
							|  |  |  | 						); | 
					
						
							|  |  |  | 						allUsedNames.add(externalNameInterop); | 
					
						
							|  |  |  | 						info.interopDefaultAccessName = externalNameInterop; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 		// Find and replace referenced to modules
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							|  |  |  | 			if (info.type === "concatenated") { | 
					
						
							|  |  |  | 				for (const reference of info.globalScope.through) { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					const name = reference.identifier.name; | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 					const match = matchModuleReference(name, modulesWithInfo); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if (match) { | 
					
						
							|  |  |  | 						const finalName = getFinalName( | 
					
						
							| 
									
										
										
										
											2018-08-07 01:39:43 +08:00
										 |  |  | 							moduleGraph, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 							match.info, | 
					
						
							|  |  |  | 							match.ids, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							moduleToInfoMap, | 
					
						
							|  |  |  | 							requestShortener, | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 							runtimeTemplate, | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 							match.call, | 
					
						
							|  |  |  | 							!match.directImport, | 
					
						
							|  |  |  | 							match.strict, | 
					
						
							|  |  |  | 							match.asiSafe | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						const r = reference.identifier.range; | 
					
						
							|  |  |  | 						const source = info.source; | 
					
						
							|  |  |  | 						source.replace(r[0], r[1] - 1, finalName); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		const result = new ConcatSource(); | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// add harmony compatibility flag (must be first because of possible circular dependencies)
 | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		if ( | 
					
						
							|  |  |  | 			moduleGraph.getExportsInfo(this).otherExportsInfo.used !== | 
					
						
							|  |  |  | 			UsageState.Unused | 
					
						
							|  |  |  | 		) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			result.add( | 
					
						
							|  |  |  | 				runtimeTemplate.defineEsModuleFlagStatement({ | 
					
						
							| 
									
										
										
										
											2018-11-17 01:18:44 +08:00
										 |  |  | 					exportsArgument: this.exportsArgument, | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 					runtimeRequirements | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				}) | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// define required namespace objects (must be before evaluation modules)
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			if (info.type === "concatenated" && info.namespaceObjectSource) { | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 				result.add(info.namespaceObjectSource); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 				runtimeRequirements.add(RuntimeGlobals.makeNamespaceObject); | 
					
						
							|  |  |  | 				runtimeRequirements.add(RuntimeGlobals.definePropertyGetters); | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// evaluate modules in order
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of modulesWithInfo) { | 
					
						
							|  |  |  | 			switch (info.type) { | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 				case "concatenated": { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					result.add( | 
					
						
							|  |  |  | 						`\n// CONCATENATED MODULE: ${info.module.readableIdentifier( | 
					
						
							|  |  |  | 							requestShortener | 
					
						
							|  |  |  | 						)}\n`
 | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					result.add(info.source); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 					if (info.runtimeRequirements) { | 
					
						
							|  |  |  | 						for (const r of info.runtimeRequirements) { | 
					
						
							|  |  |  | 							runtimeRequirements.add(r); | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					break; | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				case "external": | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					result.add( | 
					
						
							|  |  |  | 						`\n// EXTERNAL MODULE: ${info.module.readableIdentifier( | 
					
						
							|  |  |  | 							requestShortener | 
					
						
							|  |  |  | 						)}\n`
 | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 					runtimeRequirements.add(RuntimeGlobals.require); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					result.add( | 
					
						
							|  |  |  | 						`var ${info.name} = __webpack_require__(${JSON.stringify( | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 							chunkGraph.getModuleId(info.module) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						)});\n`
 | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					if (info.interopNamespaceObjectUsed) { | 
					
						
							|  |  |  | 						if (info.module.buildMeta.exportsType === "named") { | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 							runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							result.add( | 
					
						
							| 
									
										
										
										
											2019-06-13 16:51:12 +08:00
										 |  |  | 								`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${info.name}, 2);\n` | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							); | 
					
						
							|  |  |  | 						} else if (!info.module.buildMeta.exportsType) { | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 							runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							result.add( | 
					
						
							| 
									
										
										
										
											2019-06-13 16:51:12 +08:00
										 |  |  | 								`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${info.name});\n` | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							); | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if (info.interopDefaultAccessUsed) { | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 						runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						result.add( | 
					
						
							| 
									
										
										
										
											2019-06-13 16:51:12 +08:00
										 |  |  | 							`var ${info.interopDefaultAccessName} = /*#__PURE__*/${RuntimeGlobals.compatGetDefaultExport}(${info.name});\n` | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				default: | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 					// @ts-ignore never is expected here
 | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					throw new Error(`Unsupported concatenation entry type ${info.type}`); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 		return { | 
					
						
							|  |  |  | 			sources: new Map([["javascript", new CachedSource(result)]]), | 
					
						
							|  |  |  | 			runtimeRequirements | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 	_analyseModule( | 
					
						
							|  |  |  | 		info, | 
					
						
							|  |  |  | 		innerDependencyTemplates, | 
					
						
							|  |  |  | 		runtimeTemplate, | 
					
						
							|  |  |  | 		moduleGraph, | 
					
						
							|  |  |  | 		chunkGraph | 
					
						
							|  |  |  | 	) { | 
					
						
							|  |  |  | 		if (info.type === "concatenated") { | 
					
						
							|  |  |  | 			const m = info.module; | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 			const codeGenResult = m.codeGeneration({ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 				dependencyTemplates: innerDependencyTemplates, | 
					
						
							|  |  |  | 				runtimeTemplate, | 
					
						
							|  |  |  | 				moduleGraph, | 
					
						
							|  |  |  | 				chunkGraph | 
					
						
							|  |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 			const source = codeGenResult.sources.get("javascript"); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			const code = source.source(); | 
					
						
							|  |  |  | 			let ast; | 
					
						
							|  |  |  | 			try { | 
					
						
							|  |  |  | 				ast = JavascriptParser.parse(code, { | 
					
						
							|  |  |  | 					sourceType: "module" | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 			} catch (err) { | 
					
						
							|  |  |  | 				if ( | 
					
						
							|  |  |  | 					err.loc && | 
					
						
							|  |  |  | 					typeof err.loc === "object" && | 
					
						
							|  |  |  | 					typeof err.loc.line === "number" | 
					
						
							|  |  |  | 				) { | 
					
						
							|  |  |  | 					const lineNumber = err.loc.line; | 
					
						
							|  |  |  | 					const lines = code.split("\n"); | 
					
						
							|  |  |  | 					err.message += | 
					
						
							|  |  |  | 						"\n| " + | 
					
						
							|  |  |  | 						lines | 
					
						
							|  |  |  | 							.slice(Math.max(0, lineNumber - 3), lineNumber + 2) | 
					
						
							|  |  |  | 							.join("\n| "); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				throw err; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			const scopeManager = eslintScope.analyze(ast, { | 
					
						
							|  |  |  | 				ecmaVersion: 6, | 
					
						
							|  |  |  | 				sourceType: "module", | 
					
						
							|  |  |  | 				optimistic: true, | 
					
						
							|  |  |  | 				ignoreEval: true, | 
					
						
							|  |  |  | 				impliedStrict: true | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 			const globalScope = scopeManager.acquire(ast); | 
					
						
							|  |  |  | 			const moduleScope = globalScope.childScopes[0]; | 
					
						
							|  |  |  | 			const resultSource = new ReplaceSource(source); | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 			info.runtimeRequirements = codeGenResult.runtimeRequirements; | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 			info.ast = ast; | 
					
						
							|  |  |  | 			info.internalSource = source; | 
					
						
							|  |  |  | 			info.source = resultSource; | 
					
						
							|  |  |  | 			info.globalScope = globalScope; | 
					
						
							|  |  |  | 			info.moduleScope = moduleScope; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates dependency templates | 
					
						
							|  |  |  | 	 * @returns {string} hash | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	_getHashDigest(chunkGraph, dependencyTemplates) { | 
					
						
							|  |  |  | 		const hash = chunkGraph.getModuleHash(this); | 
					
						
							|  |  |  | 		const dtHash = dependencyTemplates.getHash(); | 
					
						
							|  |  |  | 		return `${hash}-${dtHash}`; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {ModuleGraph} moduleGraph the module graph | 
					
						
							|  |  |  | 	 * @returns {ModuleInfo[]} module info items | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	_getModulesWithInfo(moduleGraph) { | 
					
						
							|  |  |  | 		return this._orderedConcatenationList.map((info, idx) => { | 
					
						
							|  |  |  | 			/** @type {ModuleInfo} */ | 
					
						
							|  |  |  | 			let result; | 
					
						
							|  |  |  | 			switch (info.type) { | 
					
						
							|  |  |  | 				case "concatenated": { | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					/** @type {Map<string | true, string>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 					const exportMap = new Map(); | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					/** @type {Map<string, ReexportInfo>} */ | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 					const reexportMap = new Map(); | 
					
						
							|  |  |  | 					for (const dep of info.module.dependencies) { | 
					
						
							|  |  |  | 						if (dep instanceof HarmonyExportSpecifierDependency) { | 
					
						
							|  |  |  | 							if (!exportMap.has(dep.name)) { | 
					
						
							|  |  |  | 								exportMap.set(dep.name, dep.id); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} else if (dep instanceof HarmonyExportExpressionDependency) { | 
					
						
							|  |  |  | 							if (!exportMap.has("default")) { | 
					
						
							|  |  |  | 								exportMap.set("default", "__WEBPACK_MODULE_DEFAULT_EXPORT__"); | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} else if ( | 
					
						
							|  |  |  | 							dep instanceof HarmonyExportImportedSpecifierDependency | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							const exportName = dep.name; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 							const importNames = dep.getIds(moduleGraph); | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 							const importedModule = moduleGraph.getModule(dep); | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 							if (exportName) { | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 								if (!reexportMap.has(exportName)) { | 
					
						
							|  |  |  | 									reexportMap.set(exportName, { | 
					
						
							|  |  |  | 										module: importedModule, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 										exportName: importNames, | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 										dependency: dep | 
					
						
							|  |  |  | 									}); | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2018-12-30 16:03:42 +08:00
										 |  |  | 							} else if (importedModule) { | 
					
						
							|  |  |  | 								const providedExports = moduleGraph.getProvidedExports( | 
					
						
							|  |  |  | 									importedModule | 
					
						
							|  |  |  | 								); | 
					
						
							|  |  |  | 								if (Array.isArray(providedExports)) { | 
					
						
							|  |  |  | 									for (const name of providedExports) { | 
					
						
							|  |  |  | 										if (dep.activeExports.has(name) || name === "default") { | 
					
						
							|  |  |  | 											continue; | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 										if (!reexportMap.has(name)) { | 
					
						
							|  |  |  | 											reexportMap.set(name, { | 
					
						
							|  |  |  | 												module: importedModule, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 												exportName: [name], | 
					
						
							| 
									
										
										
										
											2018-12-30 16:03:42 +08:00
										 |  |  | 												dependency: dep | 
					
						
							|  |  |  | 											}); | 
					
						
							|  |  |  | 										} | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 									} | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					result = { | 
					
						
							|  |  |  | 						type: "concatenated", | 
					
						
							|  |  |  | 						module: info.module, | 
					
						
							|  |  |  | 						index: idx, | 
					
						
							|  |  |  | 						ast: undefined, | 
					
						
							|  |  |  | 						internalSource: undefined, | 
					
						
							| 
									
										
										
										
											2019-10-09 04:29:46 +08:00
										 |  |  | 						runtimeRequirements: undefined, | 
					
						
							| 
									
										
										
										
											2018-11-15 00:31:32 +08:00
										 |  |  | 						source: undefined, | 
					
						
							|  |  |  | 						globalScope: undefined, | 
					
						
							|  |  |  | 						moduleScope: undefined, | 
					
						
							|  |  |  | 						internalNames: new Map(), | 
					
						
							|  |  |  | 						exportMap: exportMap, | 
					
						
							|  |  |  | 						reexportMap: reexportMap, | 
					
						
							|  |  |  | 						hasNamespaceObject: false, | 
					
						
							|  |  |  | 						namespaceObjectSource: null | 
					
						
							|  |  |  | 					}; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				case "external": | 
					
						
							|  |  |  | 					result = { | 
					
						
							|  |  |  | 						type: "external", | 
					
						
							|  |  |  | 						module: info.module, | 
					
						
							|  |  |  | 						index: idx, | 
					
						
							|  |  |  | 						name: undefined, | 
					
						
							|  |  |  | 						interopNamespaceObjectUsed: false, | 
					
						
							|  |  |  | 						interopNamespaceObjectName: undefined, | 
					
						
							|  |  |  | 						interopDefaultAccessUsed: false, | 
					
						
							|  |  |  | 						interopDefaultAccessName: undefined | 
					
						
							|  |  |  | 					}; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				default: | 
					
						
							|  |  |  | 					throw new Error(`Unsupported concatenation entry type ${info.type}`); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return result; | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates outer dependency templates | 
					
						
							|  |  |  | 	 * @param {Map<Module, ModuleInfo>} moduleToInfoMap map for module info | 
					
						
							|  |  |  | 	 * @returns {DependencyTemplates} inner dependency templates | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	_getInnerDependencyTemplates(dependencyTemplates, moduleToInfoMap) { | 
					
						
							|  |  |  | 		const innerDependencyTemplates = dependencyTemplates.clone(); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyImportSpecifierDependency, | 
					
						
							|  |  |  | 			new HarmonyImportSpecifierDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyImportSpecifierDependency), | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyImportSideEffectDependency, | 
					
						
							|  |  |  | 			new HarmonyImportSideEffectDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyImportSideEffectDependency), | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyExportSpecifierDependency, | 
					
						
							|  |  |  | 			new HarmonyExportSpecifierDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyExportSpecifierDependency), | 
					
						
							|  |  |  | 				this.rootModule | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyExportExpressionDependency, | 
					
						
							|  |  |  | 			new HarmonyExportExpressionDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyExportExpressionDependency), | 
					
						
							|  |  |  | 				this.rootModule | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyExportImportedSpecifierDependency, | 
					
						
							|  |  |  | 			new HarmonyExportImportedSpecifierDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyExportImportedSpecifierDependency), | 
					
						
							|  |  |  | 				this.rootModule, | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyCompatibilityDependency, | 
					
						
							|  |  |  | 			new HarmonyCompatibilityDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyCompatibilityDependency), | 
					
						
							|  |  |  | 				this.rootModule, | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		// Must use full identifier in our cache here to ensure that the source
 | 
					
						
							|  |  |  | 		// is updated should our dependencies list change.
 | 
					
						
							|  |  |  | 		// TODO webpack 5 refactor
 | 
					
						
							|  |  |  | 		innerDependencyTemplates.updateHash(this.identifier()); | 
					
						
							|  |  |  | 		return innerDependencyTemplates; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 	findNewName(oldName, usedNamed1, usedNamed2, extraInfo) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		let name = oldName; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (name === "__WEBPACK_MODULE_DEFAULT_EXPORT__") name = ""; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-07 18:57:15 +08:00
										 |  |  | 		// Remove uncool stuff
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		extraInfo = extraInfo.replace( | 
					
						
							|  |  |  | 			/\.+\/|(\/index)?\.([a-zA-Z0-9]{1,4})($|\s|\?)|\s*\+\s*\d+\s*modules/g, | 
					
						
							|  |  |  | 			"" | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-06-07 18:57:15 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		const splittedInfo = extraInfo.split("/"); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		while (splittedInfo.length) { | 
					
						
							| 
									
										
										
										
											2017-08-07 20:38:54 +08:00
										 |  |  | 			name = splittedInfo.pop() + (name ? "_" + name : ""); | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +08:00
										 |  |  | 			const nameIdent = Template.toIdentifier(name); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if ( | 
					
						
							|  |  |  | 				!usedNamed1.has(nameIdent) && | 
					
						
							|  |  |  | 				(!usedNamed2 || !usedNamed2.has(nameIdent)) | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 				return nameIdent; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-07 22:15:49 +08:00
										 |  |  | 		let i = 0; | 
					
						
							|  |  |  | 		let nameWithNumber = Template.toIdentifier(`${name}_${i}`); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		while ( | 
					
						
							|  |  |  | 			usedNamed1.has(nameWithNumber) || | 
					
						
							|  |  |  | 			(usedNamed2 && usedNamed2.has(nameWithNumber)) | 
					
						
							|  |  |  | 		) { | 
					
						
							| 
									
										
										
										
											2017-08-07 21:43:17 +08:00
										 |  |  | 			i++; | 
					
						
							|  |  |  | 			nameWithNumber = Template.toIdentifier(`${name}_${i}`); | 
					
						
							| 
									
										
										
										
											2017-08-07 22:15:49 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-07 21:43:17 +08:00
										 |  |  | 		return nameWithNumber; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Hash} hash the hash used to track dependencies | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 	 * @param {ChunkGraph} chunkGraph the chunk graph | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 	updateHash(hash, chunkGraph) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const info of this._orderedConcatenationList) { | 
					
						
							|  |  |  | 			switch (info.type) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				case "concatenated": | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 					info.module.updateHash(hash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				case "external": | 
					
						
							| 
									
										
										
										
											2018-08-28 17:56:48 +08:00
										 |  |  | 					hash.update(`${chunkGraph.getModuleId(info.module)}`); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-07-07 17:48:52 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-23 23:07:23 +08:00
										 |  |  | 		super.updateHash(hash, chunkGraph); | 
					
						
							| 
									
										
										
										
											2017-07-07 17:48:52 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyImportSpecifierDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, modulesMap) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.modulesMap = modulesMap; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							|  |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							| 
									
										
										
										
											2018-07-18 01:38:42 +08:00
										 |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	apply(dependency, source, templateContext) { | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		const { moduleGraph, module: parentModule } = templateContext; | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		const module = moduleGraph.getModule(dep); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		const info = this.modulesMap.get(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 			this.originalTemplate.apply(dependency, source, templateContext); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		let content; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		const ids = dep.getIds(moduleGraph); | 
					
						
							|  |  |  | 		if (ids.length === 0) { | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 			content = createModuleReference({ | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				strict: parentModule.buildMeta.strictHarmonyModule, | 
					
						
							|  |  |  | 				asiSafe: dep.asiSafe | 
					
						
							|  |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		} else if (dep.namespaceObjectAsContext && ids.length === 1) { | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 			content = | 
					
						
							|  |  |  | 				createModuleReference({ | 
					
						
							|  |  |  | 					info, | 
					
						
							|  |  |  | 					strict: parentModule.buildMeta.strictHarmonyModule, | 
					
						
							|  |  |  | 					asiSafe: dep.asiSafe | 
					
						
							|  |  |  | 				}) + propertyAccess(ids); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 			content = createModuleReference({ | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				ids, | 
					
						
							|  |  |  | 				call: dep.call, | 
					
						
							|  |  |  | 				directImport: dep.directImport, | 
					
						
							|  |  |  | 				strict: parentModule.buildMeta.strictHarmonyModule, | 
					
						
							|  |  |  | 				asiSafe: dep.asiSafe | 
					
						
							|  |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.shorthand) { | 
					
						
							| 
									
										
										
										
											2019-08-29 21:28:19 +08:00
										 |  |  | 			source.insert(dep.range[1], ": " + content); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			source.replace(dep.range[0], dep.range[1] - 1, content); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyImportSideEffectDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, modulesMap) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.modulesMap = modulesMap; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							|  |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							| 
									
										
										
										
											2018-07-18 01:38:42 +08:00
										 |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	apply(dependency, source, templateContext) { | 
					
						
							|  |  |  | 		const { moduleGraph } = templateContext; | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		const dep = /** @type {HarmonyImportSideEffectDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		const module = moduleGraph.getModule(dep); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		const info = this.modulesMap.get(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 			this.originalTemplate.apply(dependency, source, templateContext); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyExportSpecifierDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, rootModule) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.rootModule = rootModule; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							|  |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							| 
									
										
										
										
											2018-07-18 01:38:42 +08:00
										 |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	apply(dependency, source, templateContext) { | 
					
						
							| 
									
										
										
										
											2018-08-07 20:20:53 +08:00
										 |  |  | 		if (templateContext.module === this.rootModule) { | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 			this.originalTemplate.apply(dependency, source, templateContext); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyExportExpressionDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, rootModule) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.rootModule = rootModule; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							|  |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 	apply( | 
					
						
							|  |  |  | 		dependency, | 
					
						
							|  |  |  | 		source, | 
					
						
							|  |  |  | 		{ module, moduleGraph, runtimeTemplate, initFragments } | 
					
						
							|  |  |  | 	) { | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 		const dep = /** @type {HarmonyExportExpressionDependency} */ (dependency); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 		if (module === this.rootModule) { | 
					
						
							|  |  |  | 			const used = module.getUsedName(moduleGraph, "default"); | 
					
						
							| 
									
										
										
										
											2019-09-03 20:10:07 +08:00
										 |  |  | 			if (used) { | 
					
						
							|  |  |  | 				const map = new Map(); | 
					
						
							|  |  |  | 				map.set(used, "__WEBPACK_MODULE_DEFAULT_EXPORT__"); | 
					
						
							|  |  |  | 				initFragments.push( | 
					
						
							|  |  |  | 					new HarmonyExportInitFragment(module.exportsArgument, map) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 02:21:07 +08:00
										 |  |  | 		const content = `/* harmony default export */ ${ | 
					
						
							|  |  |  | 			runtimeTemplate.supportsConst() ? "const" : "var" | 
					
						
							|  |  |  | 		} __WEBPACK_MODULE_DEFAULT_EXPORT__ = `;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.range) { | 
					
						
							| 
									
										
										
										
											2018-09-26 03:52:03 +08:00
										 |  |  | 			source.replace( | 
					
						
							|  |  |  | 				dep.rangeStatement[0], | 
					
						
							|  |  |  | 				dep.range[0] - 1, | 
					
						
							|  |  |  | 				content + "(" + dep.prefix | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 			source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");"); | 
					
						
							|  |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-26 03:52:03 +08:00
										 |  |  | 		source.replace( | 
					
						
							|  |  |  | 			dep.rangeStatement[0], | 
					
						
							|  |  |  | 			dep.rangeStatement[1] - 1, | 
					
						
							|  |  |  | 			content + dep.prefix | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, rootModule, modulesMap) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.rootModule = rootModule; | 
					
						
							|  |  |  | 		this.modulesMap = modulesMap; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @typedef {Object} GetExportsResultItem | 
					
						
							|  |  |  | 	 * @property {string} name | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 	 * @property {string[]} ids | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {HarmonyExportImportedSpecifierDependency} dep dependency | 
					
						
							|  |  |  | 	 * @param {DependencyTemplateContext} templateContext template context | 
					
						
							|  |  |  | 	 * @returns {GetExportsResultItem[]} exports | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	getExports(dep, { moduleGraph }) { | 
					
						
							| 
									
										
										
										
											2018-07-24 21:30:37 +08:00
										 |  |  | 		const importModule = moduleGraph.getModule(dep); | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 		const ids = dep.getIds(moduleGraph); | 
					
						
							|  |  |  | 		if (ids.length > 0) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			// export { named } from "module"
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			return [ | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: dep.name, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					ids | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			]; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.name) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			// export * as abc from "module"
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			return [ | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: dep.name, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 					ids: [] | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			]; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		// export * from "module"
 | 
					
						
							| 
									
										
										
										
											2018-12-30 16:03:42 +08:00
										 |  |  | 		const providedExports = moduleGraph.getProvidedExports(importModule); | 
					
						
							|  |  |  | 		if (Array.isArray(providedExports)) { | 
					
						
							|  |  |  | 			return providedExports | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 				.filter(exp => exp !== "default" && !dep.activeExports.has(exp)) | 
					
						
							|  |  |  | 				.map(exp => { | 
					
						
							|  |  |  | 					return { | 
					
						
							|  |  |  | 						name: exp, | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 						ids: [exp] | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 					}; | 
					
						
							|  |  |  | 				}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// unknown, should not happen
 | 
					
						
							|  |  |  | 		throw new Error("ConcatenatedModule: unknown exports"); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-27 17:45:12 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							|  |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							| 
									
										
										
										
											2018-07-27 17:45:12 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 	apply(dependency, source, templateContext) { | 
					
						
							|  |  |  | 		const { module, moduleGraph, initFragments } = templateContext; | 
					
						
							| 
									
										
										
										
											2018-07-27 17:45:12 +08:00
										 |  |  | 		const dep = /** @type {HarmonyExportImportedSpecifierDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 		const importedModule = moduleGraph.getModule(dep); | 
					
						
							|  |  |  | 		const info = this.modulesMap.get(importedModule); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 			this.originalTemplate.apply(dependency, source, templateContext); | 
					
						
							|  |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 		} else if (module === this.rootModule) { | 
					
						
							|  |  |  | 			const exportDefs = this.getExports(dep, templateContext); | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 			for (const def of exportDefs) { | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 				const used = module.getUsedName(moduleGraph, def.name); | 
					
						
							|  |  |  | 				if (!used) { | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 					initFragments.push( | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 						new HarmonyExportInitFragment( | 
					
						
							|  |  |  | 							this.rootModule.exportsArgument, | 
					
						
							|  |  |  | 							undefined, | 
					
						
							|  |  |  | 							new Set([def.name]) | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 						) | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 					); | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 					continue; | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 				let finalName; | 
					
						
							| 
									
										
										
										
											2019-03-14 19:06:59 +08:00
										 |  |  | 				if (def.ids.length === 0) { | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 					finalName = createModuleReference({ | 
					
						
							|  |  |  | 						info, | 
					
						
							|  |  |  | 						strict: module.buildMeta.strictHarmonyModule, | 
					
						
							|  |  |  | 						asiSafe: true | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2019-08-23 14:46:42 +08:00
										 |  |  | 					finalName = createModuleReference({ | 
					
						
							|  |  |  | 						info, | 
					
						
							|  |  |  | 						ids: def.ids, | 
					
						
							|  |  |  | 						strict: module.buildMeta.strictHarmonyModule, | 
					
						
							|  |  |  | 						asiSafe: true | 
					
						
							|  |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-08-09 17:46:44 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 				const map = new Map(); | 
					
						
							|  |  |  | 				map.set(used, `/* concated reexport ${finalName} */ ${finalName}`); | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 				initFragments.push( | 
					
						
							| 
									
										
										
										
											2019-08-23 20:07:01 +08:00
										 |  |  | 					new HarmonyExportInitFragment(this.rootModule.exportsArgument, map) | 
					
						
							| 
									
										
										
										
											2018-11-16 23:40:03 +08:00
										 |  |  | 				); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | class HarmonyCompatibilityDependencyConcatenatedTemplate extends DependencyTemplate { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	constructor(originalTemplate, rootModule, modulesMap) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 		super(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.originalTemplate = originalTemplate; | 
					
						
							|  |  |  | 		this.rootModule = rootModule; | 
					
						
							|  |  |  | 		this.modulesMap = modulesMap; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {Dependency} dependency the dependency for which the template should be applied | 
					
						
							|  |  |  | 	 * @param {ReplaceSource} source the current replace source which can be modified | 
					
						
							| 
									
										
										
										
											2018-07-18 01:38:42 +08:00
										 |  |  | 	 * @param {DependencyTemplateContext} templateContext the context object | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-24 23:35:36 +08:00
										 |  |  | 	apply( | 
					
						
							|  |  |  | 		dependency, | 
					
						
							|  |  |  | 		source, | 
					
						
							|  |  |  | 		{ runtimeTemplate, dependencyTemplates, moduleGraph } | 
					
						
							|  |  |  | 	) { | 
					
						
							| 
									
										
										
										
											2017-08-16 20:54:31 +08:00
										 |  |  | 		// do nothing
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ConcatenatedModule; |