| 
									
										
										
										
											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"); | 
					
						
							| 
									
										
										
										
											2018-03-22 19:05:58 +08:00
										 |  |  | const { ConcatSource, ReplaceSource } = require("webpack-sources"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const DependencyTemplate = require("../DependencyTemplate"); | 
					
						
							|  |  |  | const JavascriptParser = require("../JavascriptParser"); | 
					
						
							|  |  |  | const Module = require("../Module"); | 
					
						
							|  |  |  | const Template = require("../Template"); | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | const DependencyReference = require("../dependencies/DependencyReference"); | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); | 
					
						
							|  |  |  | const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExportExpressionDependency"); | 
					
						
							|  |  |  | const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency"); | 
					
						
							|  |  |  | 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"); | 
					
						
							| 
									
										
										
										
											2017-11-23 17:59:29 +08:00
										 |  |  | const createHash = require("../util/createHash"); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("webpack-sources").Source} Source */ | 
					
						
							| 
									
										
										
										
											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-11 19:05:13 +08:00
										 |  |  | /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | 
					
						
							| 
									
										
										
										
											2018-07-30 23:08:51 +08:00
										 |  |  | /** @typedef {import("../RequestShortener")} RequestShortener */ | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | 
					
						
							| 
									
										
										
										
											2018-07-21 00:17:51 +08:00
										 |  |  | /** @typedef {import("../util/createHash").Hash} Hash */ | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const ensureNsObjSource = ( | 
					
						
							|  |  |  | 	info, | 
					
						
							|  |  |  | 	moduleToInfoMap, | 
					
						
							|  |  |  | 	requestShortener, | 
					
						
							|  |  |  | 	strictHarmonyModule | 
					
						
							|  |  |  | ) => { | 
					
						
							|  |  |  | 	if (!info.hasNamespaceObject) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		info.hasNamespaceObject = true; | 
					
						
							|  |  |  | 		const name = info.exportMap.get(true); | 
					
						
							| 
									
										
										
										
											2018-05-03 00:09:24 +08:00
										 |  |  | 		const nsObj = [`var ${name} = {};`, `__webpack_require__.r(${name});`]; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const exportName of info.module.buildMeta.providedExports) { | 
					
						
							|  |  |  | 			const finalName = getFinalName( | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				exportName, | 
					
						
							|  |  |  | 				moduleToInfoMap, | 
					
						
							|  |  |  | 				requestShortener, | 
					
						
							|  |  |  | 				false, | 
					
						
							|  |  |  | 				strictHarmonyModule | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			nsObj.push( | 
					
						
							|  |  |  | 				`__webpack_require__.d(${name}, ${JSON.stringify( | 
					
						
							|  |  |  | 					exportName | 
					
						
							|  |  |  | 				)}, function() { return ${finalName}; });`
 | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		info.namespaceObjectSource = nsObj.join("\n") + "\n"; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const getExternalImport = ( | 
					
						
							|  |  |  | 	importedModule, | 
					
						
							|  |  |  | 	info, | 
					
						
							|  |  |  | 	exportName, | 
					
						
							|  |  |  | 	asCall, | 
					
						
							|  |  |  | 	strictHarmonyModule | 
					
						
							|  |  |  | ) => { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 	const used = importedModule.isUsed(exportName); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (!used) return "/* unused reexport */undefined"; | 
					
						
							|  |  |  | 	const comment = | 
					
						
							|  |  |  | 		used !== exportName ? ` ${Template.toNormalComment(exportName)}` : ""; | 
					
						
							|  |  |  | 	switch (importedModule.buildMeta.exportsType) { | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 		case "named": | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (exportName === "default") { | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				return info.name; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			} else if (exportName === true) { | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 				info.interopNamespaceObjectUsed = true; | 
					
						
							|  |  |  | 				return info.interopNamespaceObjectName; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 			} else { | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		case "namespace": | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (exportName === true) { | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				return info.name; | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (strictHarmonyModule) { | 
					
						
							|  |  |  | 				if (exportName === "default") { | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 					return info.name; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} else if (exportName === true) { | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 					info.interopNamespaceObjectUsed = true; | 
					
						
							|  |  |  | 					return info.interopNamespaceObjectName; | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 				} else { | 
					
						
							|  |  |  | 					return "/* non-default import from non-esm module */undefined"; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (exportName === "default") { | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 					info.interopDefaultAccessUsed = true; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					return asCall | 
					
						
							|  |  |  | 						? `${info.interopDefaultAccessName}()` | 
					
						
							|  |  |  | 						: `${info.interopDefaultAccessName}.a`; | 
					
						
							|  |  |  | 				} else if (exportName === true) { | 
					
						
							| 
									
										
										
										
											2018-01-06 04:35:36 +08:00
										 |  |  | 					return info.name; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-08-10 18:14:14 +08:00
										 |  |  | 	const reference = `${info.name}[${JSON.stringify(used)}${comment}]`; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (asCall) return `Object(${reference})`; | 
					
						
							| 
									
										
										
										
											2017-08-07 20:38:54 +08:00
										 |  |  | 	return reference; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | const getFinalName = ( | 
					
						
							|  |  |  | 	info, | 
					
						
							|  |  |  | 	exportName, | 
					
						
							|  |  |  | 	moduleToInfoMap, | 
					
						
							|  |  |  | 	requestShortener, | 
					
						
							|  |  |  | 	asCall, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 	strictHarmonyModule, | 
					
						
							|  |  |  | 	alreadyVisited = new Set() | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | ) => { | 
					
						
							|  |  |  | 	switch (info.type) { | 
					
						
							|  |  |  | 		case "concatenated": { | 
					
						
							|  |  |  | 			const directExport = info.exportMap.get(exportName); | 
					
						
							|  |  |  | 			if (directExport) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				if (exportName === true) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					ensureNsObjSource( | 
					
						
							|  |  |  | 						info, | 
					
						
							|  |  |  | 						moduleToInfoMap, | 
					
						
							|  |  |  | 						requestShortener, | 
					
						
							|  |  |  | 						strictHarmonyModule | 
					
						
							|  |  |  | 					); | 
					
						
							| 
									
										
										
										
											2018-06-23 21:27:10 +08:00
										 |  |  | 				} else if (!info.module.isUsed(exportName)) { | 
					
						
							| 
									
										
										
										
											2018-06-23 21:10:56 +08:00
										 |  |  | 					return "/* unused export */ undefined"; | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +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
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				return name; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			const reexport = info.reexportMap.get(exportName); | 
					
						
							|  |  |  | 			if (reexport) { | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 				if (alreadyVisited.has(reexport)) { | 
					
						
							|  |  |  | 					throw new Error( | 
					
						
							|  |  |  | 						`Circular reexports ${Array.from( | 
					
						
							|  |  |  | 							alreadyVisited, | 
					
						
							|  |  |  | 							e => | 
					
						
							|  |  |  | 								`"${e.module.readableIdentifier(requestShortener)}".${ | 
					
						
							|  |  |  | 									e.exportName | 
					
						
							|  |  |  | 								}`
 | 
					
						
							|  |  |  | 						).join( | 
					
						
							|  |  |  | 							" --> " | 
					
						
							|  |  |  | 						)} -(circular)-> "${reexport.module.readableIdentifier( | 
					
						
							|  |  |  | 							requestShortener | 
					
						
							|  |  |  | 						)}".${reexport.exportName}`
 | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				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( | 
					
						
							|  |  |  | 						refInfo, | 
					
						
							|  |  |  | 						reexport.exportName, | 
					
						
							|  |  |  | 						moduleToInfoMap, | 
					
						
							|  |  |  | 						requestShortener, | 
					
						
							|  |  |  | 						asCall, | 
					
						
							| 
									
										
										
										
											2018-06-20 05:19:28 +08:00
										 |  |  | 						strictHarmonyModule, | 
					
						
							|  |  |  | 						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(" ")})`; | 
					
						
							|  |  |  | 			return `${Template.toNormalComment(problem)} undefined`; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		case "external": { | 
					
						
							|  |  |  | 			const importedModule = info.module; | 
					
						
							|  |  |  | 			return getExternalImport( | 
					
						
							|  |  |  | 				importedModule, | 
					
						
							|  |  |  | 				info, | 
					
						
							|  |  |  | 				exportName, | 
					
						
							|  |  |  | 				asCall, | 
					
						
							|  |  |  | 				strictHarmonyModule | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 	var i; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 	if (Array.isArray(ast)) { | 
					
						
							|  |  |  | 		for (i = 0; i < ast.length; i++) { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 			const enterResult = enterNode(ast[i]); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (typeof 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); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (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-02-25 09:00:20 +08:00
										 |  |  | 				if (typeof pathResult !== "undefined") return pathResult; | 
					
						
							|  |  |  | 			} else if (value && typeof value === "object") { | 
					
						
							| 
									
										
										
										
											2017-06-13 19:38:12 +08:00
										 |  |  | 				const enterResult = enterNode(value); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (typeof 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | class ConcatenatedModule extends Module { | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 	constructor(rootModule, modules, concatenationList) { | 
					
						
							| 
									
										
										
										
											2018-01-31 04:40:44 +08:00
										 |  |  | 		super("javascript/esm", null); | 
					
						
							| 
									
										
										
										
											2017-06-20 20:47:38 +08:00
										 |  |  | 		super.setChunks(rootModule._chunks); | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Compilation
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.index = rootModule.index; | 
					
						
							|  |  |  | 		this.index2 = rootModule.index2; | 
					
						
							|  |  |  | 		this.depth = rootModule.depth; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Optimization
 | 
					
						
							|  |  |  | 		this.used = rootModule.used; | 
					
						
							|  |  |  | 		this.usedExports = rootModule.usedExports; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Info from Build
 | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.buildInfo = { | 
					
						
							|  |  |  | 			strict: true, | 
					
						
							|  |  |  | 			cacheable: modules.every(m => m.buildInfo.cacheable), | 
					
						
							|  |  |  | 			moduleArgument: rootModule.buildInfo.moduleArgument, | 
					
						
							|  |  |  | 			exportsArgument: rootModule.buildInfo.exportsArgument, | 
					
						
							|  |  |  | 			fileDependencies: new Set(), | 
					
						
							|  |  |  | 			contextDependencies: new Set(), | 
					
						
							|  |  |  | 			assets: undefined | 
					
						
							|  |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		this.built = modules.some(m => m.built); | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 		this.buildMeta = rootModule.buildMeta; | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Caching
 | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 		this._numberOfConcatenatedModules = modules.length; | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 		// Graph
 | 
					
						
							|  |  |  | 		const modulesSet = new Set(modules); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		this.reasons = rootModule.reasons.filter( | 
					
						
							|  |  |  | 			reason => | 
					
						
							|  |  |  | 				!(reason.dependency instanceof HarmonyImportDependency) || | 
					
						
							|  |  |  | 				!modulesSet.has(reason.module) | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-11-06 20:02:35 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 		this.dependencies = []; | 
					
						
							| 
									
										
										
										
											2017-12-06 19:09:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 		this.warnings = []; | 
					
						
							|  |  |  | 		this.errors = []; | 
					
						
							| 
									
										
										
										
											2018-06-08 16:34:38 +08:00
										 |  |  | 		this._orderedConcatenationList = | 
					
						
							|  |  |  | 			concatenationList || | 
					
						
							|  |  |  | 			ConcatenatedModule.createConcatenationList(rootModule, modulesSet, null); | 
					
						
							| 
									
										
										
										
											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-05-27 05:07:02 +08:00
										 |  |  | 						!modulesSet.has(dep._module) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				)) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 					this.dependencies.push(d); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate file dependencies
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (m.buildInfo.fileDependencies) { | 
					
						
							|  |  |  | 					for (const file of m.buildInfo.fileDependencies) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 						this.buildInfo.fileDependencies.add(file); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate context dependencies
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				if (m.buildInfo.contextDependencies) { | 
					
						
							|  |  |  | 					for (const context of m.buildInfo.contextDependencies) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 						this.buildInfo.contextDependencies.add(context); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate warnings
 | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				for (const warning of m.warnings) { | 
					
						
							|  |  |  | 					this.warnings.push(warning); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 				// populate errors
 | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 				for (const error of m.errors) { | 
					
						
							|  |  |  | 					this.errors.push(error); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-06-18 20:46:06 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 		this._identifier = this._createIdentifier(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {TODO} options TODO | 
					
						
							|  |  |  | 	 * @param {Compilation} compilation the compilation | 
					
						
							|  |  |  | 	 * @param {TODO} resolver TODO | 
					
						
							|  |  |  | 	 * @param {TODO} fs the file system | 
					
						
							|  |  |  | 	 * @param {function(Error=): void} callback callback function | 
					
						
							|  |  |  | 	 * @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
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @returns {number} the estimated size of the module | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	size() { | 
					
						
							|  |  |  | 		// 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": | 
					
						
							|  |  |  | 					return sum + info.module.size(); | 
					
						
							|  |  |  | 				case "external": | 
					
						
							|  |  |  | 					return sum + 5; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			return sum; | 
					
						
							|  |  |  | 		}, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	static createConcatenationList(rootModule, modulesSet, 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 => { | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | 			const references = module.dependencies | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 				.filter(dep => dep instanceof HarmonyImportDependency) | 
					
						
							| 
									
										
										
										
											2018-07-23 03:01:05 +08:00
										 |  |  | 				.map(dep => compilation.getDependencyReference(module, dep)) | 
					
						
							|  |  |  | 				.filter(ref => ref !== null); | 
					
						
							| 
									
										
										
										
											2018-06-08 19:20:57 +08:00
										 |  |  | 			DependencyReference.sort(references); | 
					
						
							|  |  |  | 			return references.map(ref => { | 
					
						
							| 
									
										
										
										
											2018-07-23 03:01:05 +08:00
										 |  |  | 				return () => ref.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
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 00:14:39 +08:00
										 |  |  | 	_createIdentifier() { | 
					
						
							| 
									
										
										
										
											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") { | 
					
						
							|  |  |  | 				orderedConcatenationListIdentifiers += this._orderedConcatenationList[ | 
					
						
							|  |  |  | 					i | 
					
						
							|  |  |  | 				].module.identifier(); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 		return this.rootModule.identifier() + " " + hash.digest("hex"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {string=} type the type of source that should be returned | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 	 * @returns {Source} generated source | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-07-25 18:12:17 +08:00
										 |  |  | 	source(dependencyTemplates, runtimeTemplate, type) { | 
					
						
							| 
									
										
										
										
											2017-12-07 17:31:00 +08:00
										 |  |  | 		const requestShortener = runtimeTemplate.requestShortener; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		// Metainfo for each module
 | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 		const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			switch (info.type) { | 
					
						
							|  |  |  | 				case "concatenated": { | 
					
						
							|  |  |  | 					const exportMap = new Map(); | 
					
						
							|  |  |  | 					const reexportMap = new Map(); | 
					
						
							|  |  |  | 					for (const dep of info.module.dependencies) { | 
					
						
							|  |  |  | 						if (dep instanceof HarmonyExportSpecifierDependency) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 							if (!exportMap.has(dep.name)) { | 
					
						
							|  |  |  | 								exportMap.set(dep.name, dep.id); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} else if (dep instanceof HarmonyExportExpressionDependency) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 							if (!exportMap.has("default")) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								exportMap.set("default", "__WEBPACK_MODULE_DEFAULT_EXPORT__"); | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} else if ( | 
					
						
							|  |  |  | 							dep instanceof HarmonyExportImportedSpecifierDependency | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							const exportName = dep.name; | 
					
						
							|  |  |  | 							const importName = dep.id; | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 							const importedModule = dep._module; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							if (exportName && importName) { | 
					
						
							|  |  |  | 								if (!reexportMap.has(exportName)) { | 
					
						
							|  |  |  | 									reexportMap.set(exportName, { | 
					
						
							|  |  |  | 										module: importedModule, | 
					
						
							|  |  |  | 										exportName: importName, | 
					
						
							|  |  |  | 										dependency: dep | 
					
						
							|  |  |  | 									}); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} else if (exportName) { | 
					
						
							|  |  |  | 								if (!reexportMap.has(exportName)) { | 
					
						
							|  |  |  | 									reexportMap.set(exportName, { | 
					
						
							|  |  |  | 										module: importedModule, | 
					
						
							|  |  |  | 										exportName: true, | 
					
						
							|  |  |  | 										dependency: dep | 
					
						
							|  |  |  | 									}); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} else if (importedModule) { | 
					
						
							|  |  |  | 								for (const name of importedModule.buildMeta.providedExports) { | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 									if (dep.activeExports.has(name) || name === "default") { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 										continue; | 
					
						
							| 
									
										
										
										
											2018-05-29 20:50:40 +08:00
										 |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 									if (!reexportMap.has(name)) { | 
					
						
							|  |  |  | 										reexportMap.set(name, { | 
					
						
							| 
									
										
										
										
											2017-08-07 21:43:17 +08:00
										 |  |  | 											module: importedModule, | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 											exportName: name, | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 											dependency: dep | 
					
						
							|  |  |  | 										}); | 
					
						
							| 
									
										
										
										
											2017-10-09 21:28:59 +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
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					return { | 
					
						
							|  |  |  | 						type: "concatenated", | 
					
						
							|  |  |  | 						module: info.module, | 
					
						
							|  |  |  | 						index: idx, | 
					
						
							|  |  |  | 						ast: undefined, | 
					
						
							|  |  |  | 						internalSource: undefined, | 
					
						
							|  |  |  | 						source: undefined, | 
					
						
							|  |  |  | 						globalScope: undefined, | 
					
						
							|  |  |  | 						moduleScope: undefined, | 
					
						
							|  |  |  | 						internalNames: new Map(), | 
					
						
							|  |  |  | 						exportMap: exportMap, | 
					
						
							|  |  |  | 						reexportMap: reexportMap, | 
					
						
							|  |  |  | 						hasNamespaceObject: false, | 
					
						
							|  |  |  | 						namespaceObjectSource: null | 
					
						
							|  |  |  | 					}; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 				case "external": | 
					
						
							|  |  |  | 					return { | 
					
						
							|  |  |  | 						type: "external", | 
					
						
							|  |  |  | 						module: info.module, | 
					
						
							|  |  |  | 						index: idx, | 
					
						
							| 
									
										
										
										
											2017-08-10 18:14:14 +08:00
										 |  |  | 						name: undefined, | 
					
						
							| 
									
										
										
										
											2018-01-06 05:35:54 +08:00
										 |  |  | 						interopNamespaceObjectUsed: false, | 
					
						
							|  |  |  | 						interopNamespaceObjectName: undefined, | 
					
						
							|  |  |  | 						interopDefaultAccessUsed: false, | 
					
						
							|  |  |  | 						interopDefaultAccessName: undefined | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					}; | 
					
						
							|  |  |  | 				default: | 
					
						
							|  |  |  | 					throw new Error(`Unsupported concatenation entry type ${info.type}`); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Create mapping from module to info
 | 
					
						
							|  |  |  | 		const moduleToInfoMap = new Map(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		for (const m of modulesWithInfo) { | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 			moduleToInfoMap.set(m.module, m); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Configure template decorators for dependencies
 | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 		const innerDependencyTemplates = dependencyTemplates.clone(); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		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), | 
					
						
							| 
									
										
										
										
											2018-03-29 13:06:44 +08:00
										 |  |  | 				this.rootModule | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyExportImportedSpecifierDependency, | 
					
						
							|  |  |  | 			new HarmonyExportImportedSpecifierDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyExportImportedSpecifierDependency), | 
					
						
							|  |  |  | 				this.rootModule, | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 		innerDependencyTemplates.set( | 
					
						
							|  |  |  | 			HarmonyCompatibilityDependency, | 
					
						
							|  |  |  | 			new HarmonyCompatibilityDependencyConcatenatedTemplate( | 
					
						
							|  |  |  | 				dependencyTemplates.get(HarmonyCompatibilityDependency), | 
					
						
							|  |  |  | 				this.rootModule, | 
					
						
							|  |  |  | 				moduleToInfoMap | 
					
						
							|  |  |  | 			) | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-04-29 04:32:28 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Must use full identifier in our cache here to ensure that the source
 | 
					
						
							|  |  |  | 		// is updated should our dependencies list change.
 | 
					
						
							| 
									
										
										
										
											2018-06-25 22:18:21 +08:00
										 |  |  | 		// TODO webpack 5 refactor
 | 
					
						
							| 
									
										
										
										
											2018-07-11 19:05:13 +08:00
										 |  |  | 		innerDependencyTemplates.updateHash(this.identifier()); | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							|  |  |  | 			if (info.type === "concatenated") { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 				const m = info.module; | 
					
						
							| 
									
										
										
										
											2017-12-07 17:31:00 +08:00
										 |  |  | 				const source = m.source(innerDependencyTemplates, runtimeTemplate); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 				const code = source.source(); | 
					
						
							|  |  |  | 				let ast; | 
					
						
							|  |  |  | 				try { | 
					
						
							| 
									
										
										
										
											2018-07-03 16:15:48 +08:00
										 |  |  | 					ast = JavascriptParser.parse(code, { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						sourceType: "module" | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					}); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				} catch (err) { | 
					
						
							|  |  |  | 					if ( | 
					
						
							|  |  |  | 						err.loc && | 
					
						
							|  |  |  | 						typeof err.loc === "object" && | 
					
						
							|  |  |  | 						typeof err.loc.line === "number" | 
					
						
							|  |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						const lineNumber = err.loc.line; | 
					
						
							|  |  |  | 						const lines = code.split("\n"); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						err.message += | 
					
						
							|  |  |  | 							"\n| " + | 
					
						
							|  |  |  | 							lines | 
					
						
							|  |  |  | 								.slice(Math.max(0, lineNumber - 3), lineNumber + 2) | 
					
						
							|  |  |  | 								.join("\n| "); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					throw err; | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-11-24 07:47:01 +08:00
										 |  |  | 				const scopeManager = eslintScope.analyze(ast, { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					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); | 
					
						
							|  |  |  | 				info.ast = ast; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 				info.internalSource = source; | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 				info.source = resultSource; | 
					
						
							|  |  |  | 				info.globalScope = globalScope; | 
					
						
							|  |  |  | 				info.moduleScope = moduleScope; | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// List of all used names to avoid conflicts
 | 
					
						
							| 
									
										
										
										
											2017-08-07 20:47:45 +08:00
										 |  |  | 		const allUsedNames = new Set([ | 
					
						
							| 
									
										
										
										
											2017-08-07 21:43:17 +08:00
										 |  |  | 			"__WEBPACK_MODULE_DEFAULT_EXPORT__", // avoid using this internal name
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			"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", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"module", | 
					
						
							|  |  |  | 			"__dirname", | 
					
						
							|  |  |  | 			"__filename", | 
					
						
							|  |  |  | 			"exports", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"Array", | 
					
						
							|  |  |  | 			"Date", | 
					
						
							|  |  |  | 			"eval", | 
					
						
							|  |  |  | 			"function", | 
					
						
							|  |  |  | 			"hasOwnProperty", | 
					
						
							|  |  |  | 			"Infinity", | 
					
						
							|  |  |  | 			"isFinite", | 
					
						
							|  |  |  | 			"isNaN", | 
					
						
							|  |  |  | 			"isPrototypeOf", | 
					
						
							|  |  |  | 			"length", | 
					
						
							|  |  |  | 			"Math", | 
					
						
							|  |  |  | 			"NaN", | 
					
						
							|  |  |  | 			"name", | 
					
						
							|  |  |  | 			"Number", | 
					
						
							|  |  |  | 			"Object", | 
					
						
							|  |  |  | 			"prototype", | 
					
						
							|  |  |  | 			"String", | 
					
						
							|  |  |  | 			"toString", | 
					
						
							|  |  |  | 			"undefined", | 
					
						
							|  |  |  | 			"valueOf", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"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", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"onblur", | 
					
						
							|  |  |  | 			"onclick", | 
					
						
							|  |  |  | 			"onerror", | 
					
						
							|  |  |  | 			"onfocus", | 
					
						
							|  |  |  | 			"onkeydown", | 
					
						
							|  |  |  | 			"onkeypress", | 
					
						
							|  |  |  | 			"onkeyup", | 
					
						
							|  |  |  | 			"onmouseover", | 
					
						
							|  |  |  | 			"onload", | 
					
						
							|  |  |  | 			"onmouseup", | 
					
						
							|  |  |  | 			"onmousedown", | 
					
						
							|  |  |  | 			"onsubmit" | 
					
						
							| 
									
										
										
										
											2017-08-07 20:47:45 +08:00
										 |  |  | 		]); | 
					
						
							| 
									
										
										
										
											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-03-29 20:43:01 +08:00
										 |  |  | 			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 | 
					
						
							|  |  |  | 					}); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// add global symbols
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (info.globalScope) { | 
					
						
							|  |  |  | 				for (const reference of info.globalScope.through) { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					const name = reference.identifier.name; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if ( | 
					
						
							|  |  |  | 						/^__WEBPACK_MODULE_REFERENCE__\d+_([\da-f]+|ns)(_call)?(_strict)?__$/.test( | 
					
						
							|  |  |  | 							name | 
					
						
							|  |  |  | 						) | 
					
						
							|  |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +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); | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-03-29 20:43:01 +08:00
										 |  |  | 						addScopeSymbols1( | 
					
						
							|  |  |  | 							reference.from, | 
					
						
							|  |  |  | 							allUsedNames, | 
					
						
							|  |  |  | 							alreadyCheckedScopes | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					} else { | 
					
						
							|  |  |  | 						allUsedNames.add(name); | 
					
						
							| 
									
										
										
										
											2017-05-31 22:46:25 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					const match = /^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?(_strict)?__$/.exec( | 
					
						
							|  |  |  | 						name | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					if (match) { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						const referencedModule = modulesWithInfo[+match[1]]; | 
					
						
							|  |  |  | 						let exportName; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						if (match[2] === "ns") { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 							exportName = true; | 
					
						
							|  |  |  | 						} else { | 
					
						
							| 
									
										
										
										
											2017-08-07 19:56:50 +08:00
										 |  |  | 							const exportData = match[2]; | 
					
						
							| 
									
										
										
										
											2018-01-22 22:00:12 +08:00
										 |  |  | 							exportName = Buffer.from(exportData, "hex").toString("utf-8"); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						const asCall = !!match[3]; | 
					
						
							| 
									
										
										
										
											2017-11-23 21:10:52 +08:00
										 |  |  | 						const strictHarmonyModule = !!match[4]; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						const finalName = getFinalName( | 
					
						
							|  |  |  | 							referencedModule, | 
					
						
							|  |  |  | 							exportName, | 
					
						
							|  |  |  | 							moduleToInfoMap, | 
					
						
							|  |  |  | 							requestShortener, | 
					
						
							|  |  |  | 							asCall, | 
					
						
							|  |  |  | 							strictHarmonyModule | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											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)
 | 
					
						
							| 
									
										
										
										
											2017-08-16 20:54:31 +08:00
										 |  |  | 		const usedExports = this.rootModule.usedExports; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (usedExports === true) { | 
					
						
							|  |  |  | 			result.add( | 
					
						
							|  |  |  | 				runtimeTemplate.defineEsModuleFlagStatement({ | 
					
						
							|  |  |  | 					exportsArgument: this.exportsArgument | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							|  |  |  | 			if (info.namespaceObjectSource) { | 
					
						
							| 
									
										
										
										
											2017-08-07 20:12:31 +08:00
										 |  |  | 				result.add(info.namespaceObjectSource); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +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); | 
					
						
							|  |  |  | 					break; | 
					
						
							| 
									
										
										
										
											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`
 | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					result.add( | 
					
						
							|  |  |  | 						`var ${info.name} = __webpack_require__(${JSON.stringify( | 
					
						
							|  |  |  | 							info.module.id | 
					
						
							|  |  |  | 						)});\n`
 | 
					
						
							|  |  |  | 					); | 
					
						
							|  |  |  | 					if (info.interopNamespaceObjectUsed) { | 
					
						
							|  |  |  | 						if (info.module.buildMeta.exportsType === "named") { | 
					
						
							|  |  |  | 							result.add( | 
					
						
							|  |  |  | 								`var ${ | 
					
						
							|  |  |  | 									info.interopNamespaceObjectName | 
					
						
							| 
									
										
										
										
											2018-05-03 00:09:24 +08:00
										 |  |  | 								} = /*#__PURE__*/__webpack_require__.t(${info.name}, 2);\n`
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							); | 
					
						
							|  |  |  | 						} else if (!info.module.buildMeta.exportsType) { | 
					
						
							|  |  |  | 							result.add( | 
					
						
							|  |  |  | 								`var ${ | 
					
						
							|  |  |  | 									info.interopNamespaceObjectName | 
					
						
							| 
									
										
										
										
											2018-05-03 00:09:24 +08:00
										 |  |  | 								} = /*#__PURE__*/__webpack_require__.t(${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) { | 
					
						
							|  |  |  | 						result.add( | 
					
						
							|  |  |  | 							`var ${ | 
					
						
							|  |  |  | 								info.interopDefaultAccessName | 
					
						
							|  |  |  | 							} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`
 | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2017-08-07 19:19:24 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-08-07 17:53:07 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				default: | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | 		return result; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-07-07 17:48:52 +08:00
										 |  |  | 	updateHash(hash) { | 
					
						
							| 
									
										
										
										
											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": | 
					
						
							|  |  |  | 					info.module.updateHash(hash); | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				case "external": | 
					
						
							|  |  |  | 					hash.update(`${info.module.id}`); | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-07-07 17:48:52 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		super.updateHash(hash); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											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-23 20:53:50 +08:00
										 |  |  | 	getInitFragments(dep, source, runtime) { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const module = dep._module; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		const info = this.modulesMap.get(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-07-23 20:53:50 +08:00
										 |  |  | 			return this.originalTemplate.getInitFragments(dep, source, runtime); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			return []; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 		const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const module = dep._module; | 
					
						
							| 
									
										
										
										
											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-25 19:16:08 +08:00
										 |  |  | 			this.originalTemplate.apply( | 
					
						
							|  |  |  | 				dependency, | 
					
						
							|  |  |  | 				source, | 
					
						
							|  |  |  | 				runtimeTemplate, | 
					
						
							|  |  |  | 				dependencyTemplates | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		let content; | 
					
						
							| 
									
										
										
										
											2017-11-23 21:10:52 +08:00
										 |  |  | 		const callFlag = dep.call ? "_call" : ""; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		const strictFlag = dep.originModule.buildMeta.strictHarmonyModule | 
					
						
							|  |  |  | 			? "_strict" | 
					
						
							|  |  |  | 			: ""; | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		if (dep._id === null) { | 
					
						
							| 
									
										
										
										
											2017-11-23 21:10:52 +08:00
										 |  |  | 			content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		} else if (dep.namespaceObjectAsContext) { | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 			content = `__WEBPACK_MODULE_REFERENCE__${ | 
					
						
							|  |  |  | 				info.index | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 			}_ns${strictFlag}__[${JSON.stringify(dep._id)}]`;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 			const exportData = Buffer.from(dep._id, "utf-8").toString("hex"); | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 			content = `__WEBPACK_MODULE_REFERENCE__${ | 
					
						
							|  |  |  | 				info.index | 
					
						
							|  |  |  | 			}_${exportData}${callFlag}${strictFlag}__`;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.shorthand) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			content = dep.name + ": " + content; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		source.replace(dep.range[0], dep.range[1] - 1, content); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-23 20:53:50 +08:00
										 |  |  | 	getInitFragments(dep, source, runtime) { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const module = dep._module; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		const info = this.modulesMap.get(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-07-23 20:53:50 +08:00
										 |  |  | 			return this.originalTemplate.getInitFragments(dep, source, runtime); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			return []; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 		const dep = /** @type {HarmonyImportSideEffectDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const module = dep._module; | 
					
						
							| 
									
										
										
										
											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-25 19:16:08 +08:00
										 |  |  | 			this.originalTemplate.apply( | 
					
						
							|  |  |  | 				dependency, | 
					
						
							|  |  |  | 				source, | 
					
						
							|  |  |  | 				runtimeTemplate, | 
					
						
							|  |  |  | 				dependencyTemplates | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											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-23 20:53:50 +08:00
										 |  |  | 	getInitFragments(dep, source, runtime) { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.originModule === this.rootModule) { | 
					
						
							| 
									
										
										
										
											2018-07-23 20:53:50 +08:00
										 |  |  | 			return this.originalTemplate.getInitFragments(dep, source, runtime); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			return []; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 		const dep = /** @type {HarmonyExportSpecifierDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.originModule === this.rootModule) { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 			this.originalTemplate.apply( | 
					
						
							|  |  |  | 				dependency, | 
					
						
							|  |  |  | 				source, | 
					
						
							|  |  |  | 				runtimeTemplate, | 
					
						
							|  |  |  | 				dependencyTemplates | 
					
						
							|  |  |  | 			); | 
					
						
							| 
									
										
										
										
											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-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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 		const dep = /** @type {HarmonyExportExpressionDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		let content = | 
					
						
							|  |  |  | 			"/* harmony default export */ var __WEBPACK_MODULE_DEFAULT_EXPORT__ = "; | 
					
						
							|  |  |  | 		if (dep.originModule === this.rootModule) { | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 			const used = dep.originModule.isUsed("default"); | 
					
						
							| 
									
										
										
										
											2017-11-12 01:48:29 +08:00
										 |  |  | 			const exportsName = dep.originModule.exportsArgument; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			if (used) content += `${exportsName}[${JSON.stringify(used)}] = `; | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.range) { | 
					
						
							| 
									
										
										
										
											2017-07-22 05:32:31 +08:00
										 |  |  | 			source.replace(dep.rangeStatement[0], dep.range[0] - 1, content + "("); | 
					
						
							|  |  |  | 			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
										 |  |  | 
 | 
					
						
							|  |  |  | 		source.replace(dep.rangeStatement[0], dep.rangeStatement[1] - 1, content); | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	getExports(dep) { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const importModule = dep._module; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.id) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			// export { named } from "module"
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			return [ | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					name: dep.name, | 
					
						
							|  |  |  | 					id: dep.id, | 
					
						
							|  |  |  | 					module: importModule | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			]; | 
					
						
							| 
									
										
										
										
											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, | 
					
						
							|  |  |  | 					id: true, | 
					
						
							|  |  |  | 					module: importModule | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			]; | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		// export * from "module"
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		return importModule.buildMeta.providedExports | 
					
						
							|  |  |  | 			.filter(exp => exp !== "default" && !dep.activeExports.has(exp)) | 
					
						
							|  |  |  | 			.map(exp => { | 
					
						
							|  |  |  | 				return { | 
					
						
							|  |  |  | 					name: exp, | 
					
						
							|  |  |  | 					id: exp, | 
					
						
							|  |  |  | 					module: importModule | 
					
						
							|  |  |  | 				}; | 
					
						
							|  |  |  | 			}); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-23 20:53:50 +08:00
										 |  |  | 	getInitFragments(dep, source, runtime) { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 		const module = dep._module; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		const info = this.modulesMap.get(module); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (!info) { | 
					
						
							| 
									
										
										
										
											2018-07-23 20:53:50 +08:00
										 |  |  | 			return this.originalTemplate.getInitFragments(dep, source, runtime); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			return []; | 
					
						
							| 
									
										
										
										
											2017-08-08 15:32:43 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							|  |  |  | 		const dep = /** @type {HarmonyExportImportedSpecifierDependency} */ (dependency); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 		if (dep.originModule === this.rootModule) { | 
					
						
							| 
									
										
										
										
											2018-05-27 05:07:02 +08:00
										 |  |  | 			if (this.modulesMap.get(dep._module)) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 				const exportDefs = this.getExports(dep); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				for (const def of exportDefs) { | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					const info = this.modulesMap.get(def.module); | 
					
						
							|  |  |  | 					const used = dep.originModule.isUsed(def.name); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					if (!used) { | 
					
						
							|  |  |  | 						source.insert( | 
					
						
							|  |  |  | 							-1, | 
					
						
							|  |  |  | 							`/* unused concated harmony import ${dep.name} */\n` | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					let finalName; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					const strictFlag = dep.originModule.buildMeta.strictHarmonyModule | 
					
						
							|  |  |  | 						? "_strict" | 
					
						
							|  |  |  | 						: ""; | 
					
						
							|  |  |  | 					if (def.id === true) { | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 						finalName = `__WEBPACK_MODULE_REFERENCE__${ | 
					
						
							|  |  |  | 							info.index | 
					
						
							|  |  |  | 						}_ns${strictFlag}__`;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2018-01-22 22:00:12 +08:00
										 |  |  | 						const exportData = Buffer.from(def.id, "utf-8").toString("hex"); | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 						finalName = `__WEBPACK_MODULE_REFERENCE__${ | 
					
						
							|  |  |  | 							info.index | 
					
						
							|  |  |  | 						}_${exportData}${strictFlag}__`;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2017-11-12 01:48:29 +08:00
										 |  |  | 					const exportsName = this.rootModule.exportsArgument; | 
					
						
							| 
									
										
										
										
											2018-03-26 22:56:10 +08:00
										 |  |  | 					const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify( | 
					
						
							|  |  |  | 						used | 
					
						
							|  |  |  | 					)}, function() { return ${finalName}; });\n`;
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 					source.insert(-1, content); | 
					
						
							| 
									
										
										
										
											2018-01-22 20:52:43 +08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2018-07-25 19:16:08 +08:00
										 |  |  | 				this.originalTemplate.apply( | 
					
						
							|  |  |  | 					dependency, | 
					
						
							|  |  |  | 					source, | 
					
						
							|  |  |  | 					runtimeTemplate, | 
					
						
							|  |  |  | 					dependencyTemplates | 
					
						
							|  |  |  | 				); | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | 	 * @param {RuntimeTemplate} runtimeTemplate the runtime template | 
					
						
							|  |  |  | 	 * @param {DependencyTemplates} dependencyTemplates the dependency templates | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	apply(dependency, source, runtimeTemplate, dependencyTemplates) { | 
					
						
							| 
									
										
										
										
											2017-08-16 20:54:31 +08:00
										 |  |  | 		// do nothing
 | 
					
						
							| 
									
										
										
										
											2017-05-10 19:15:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = ConcatenatedModule; |