| 
									
										
										
										
											2015-05-13 06:15:01 +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-02-23 23:00:38 +08:00
										 |  |  | "use strict"; | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-14 22:01:25 +08:00
										 |  |  | const util = require("util"); | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | const ExternalModule = require("./ExternalModule"); | 
					
						
							| 
									
										
										
										
											2024-03-16 00:59:30 +08:00
										 |  |  | const ContextElementDependency = require("./dependencies/ContextElementDependency"); | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | const CssImportDependency = require("./dependencies/CssImportDependency"); | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | const HarmonyImportDependency = require("./dependencies/HarmonyImportDependency"); | 
					
						
							|  |  |  | const ImportDependency = require("./dependencies/ImportDependency"); | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | const { resolveByProperty, cachedSetProperty } = require("./util/cleverMerge"); | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */ | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | /** @typedef {import("./Compilation").DepConstructor} DepConstructor */ | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | /** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */ | 
					
						
							|  |  |  | /** @typedef {import("./Module")} Module */ | 
					
						
							|  |  |  | /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */ | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-08 03:56:53 +08:00
										 |  |  | const UNSPECIFIED_EXTERNAL_TYPE_REGEXP = /^[a-z0-9-]+ /; | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | const EMPTY_RESOLVE_OPTIONS = {}; | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 17:10:26 +08:00
										 |  |  | // TODO webpack 6 remove this
 | 
					
						
							|  |  |  | const callDeprecatedExternals = util.deprecate( | 
					
						
							|  |  |  | 	(externalsFunction, context, request, cb) => { | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 		// eslint-disable-next-line no-useless-call
 | 
					
						
							| 
									
										
										
										
											2019-11-15 17:10:26 +08:00
										 |  |  | 		externalsFunction.call(null, context, request, cb); | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	"The externals-function should be defined like ({context, request}, cb) => { ... }", | 
					
						
							|  |  |  | 	"DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS" | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 18:14:23 +08:00
										 |  |  | const cache = new WeakMap(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-08 02:59:26 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @param {object} obj obj | 
					
						
							|  |  |  |  * @param {TODO} layer layer | 
					
						
							|  |  |  |  * @returns {object} result | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-01-06 18:14:23 +08:00
										 |  |  | const resolveLayer = (obj, layer) => { | 
					
						
							|  |  |  | 	let map = cache.get(obj); | 
					
						
							|  |  |  | 	if (map === undefined) { | 
					
						
							|  |  |  | 		map = new Map(); | 
					
						
							|  |  |  | 		cache.set(obj, map); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		const cacheEntry = map.get(layer); | 
					
						
							|  |  |  | 		if (cacheEntry !== undefined) return cacheEntry; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	const result = resolveByProperty(obj, "byLayer", layer); | 
					
						
							|  |  |  | 	map.set(layer, result); | 
					
						
							|  |  |  | 	return result; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-08 02:59:26 +08:00
										 |  |  | /** @typedef {string|string[]|boolean|Record<string, string|string[]>} ExternalValue */ | 
					
						
							|  |  |  | /** @typedef {string|undefined} ExternalType */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | class ExternalModuleFactoryPlugin { | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {string | undefined} type default external type | 
					
						
							|  |  |  | 	 * @param {Externals} externals externals config | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2024-08-19 19:50:35 +08:00
										 |  |  | 	constructor(type, externals) { | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | 		this.type = type; | 
					
						
							|  |  |  | 		this.externals = externals; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param {NormalModuleFactory} normalModuleFactory the normal module factory | 
					
						
							|  |  |  | 	 * @returns {void} | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | 	apply(normalModuleFactory) { | 
					
						
							|  |  |  | 		const globalType = this.type; | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 		normalModuleFactory.hooks.factorize.tapAsync( | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			"ExternalModuleFactoryPlugin", | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 			(data, callback) => { | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const context = data.context; | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 				const contextInfo = data.contextInfo; | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const dependency = data.dependencies[0]; | 
					
						
							| 
									
										
										
										
											2021-08-05 23:04:52 +08:00
										 |  |  | 				const dependencyType = data.dependencyType; | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 				/** | 
					
						
							| 
									
										
										
										
											2024-08-08 02:59:26 +08:00
										 |  |  | 				 * @param {ExternalValue} value the external config | 
					
						
							|  |  |  | 				 * @param {ExternalType | undefined} type type of external | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 				 * @param {function((Error | null)=, ExternalModule=): void} callback callback | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 				 * @returns {void} | 
					
						
							|  |  |  | 				 */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const handleExternal = (value, type, callback) => { | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 					if (value === false) { | 
					
						
							|  |  |  | 						// Not externals, fallback to original factory
 | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 						return callback(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 					/** @type {string | string[] | Record<string, string|string[]>} */ | 
					
						
							| 
									
										
										
										
											2024-08-02 02:36:27 +08:00
										 |  |  | 					let externalConfig = value === true ? dependency.request : value; | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 					// When no explicit type is specified, extract it from the externalConfig
 | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 					if (type === undefined) { | 
					
						
							|  |  |  | 						if ( | 
					
						
							|  |  |  | 							typeof externalConfig === "string" && | 
					
						
							|  |  |  | 							UNSPECIFIED_EXTERNAL_TYPE_REGEXP.test(externalConfig) | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							const idx = externalConfig.indexOf(" "); | 
					
						
							| 
									
										
										
										
											2022-03-14 05:54:18 +08:00
										 |  |  | 							type = externalConfig.slice(0, idx); | 
					
						
							|  |  |  | 							externalConfig = externalConfig.slice(idx + 1); | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 						} else if ( | 
					
						
							|  |  |  | 							Array.isArray(externalConfig) && | 
					
						
							|  |  |  | 							externalConfig.length > 0 && | 
					
						
							|  |  |  | 							UNSPECIFIED_EXTERNAL_TYPE_REGEXP.test(externalConfig[0]) | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							const firstItem = externalConfig[0]; | 
					
						
							|  |  |  | 							const idx = firstItem.indexOf(" "); | 
					
						
							| 
									
										
										
										
											2022-03-14 05:54:18 +08:00
										 |  |  | 							type = firstItem.slice(0, idx); | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 							externalConfig = [ | 
					
						
							| 
									
										
										
										
											2022-03-14 05:54:18 +08:00
										 |  |  | 								firstItem.slice(idx + 1), | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 								...externalConfig.slice(1) | 
					
						
							|  |  |  | 							]; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 					// TODO make it pluggable/add hooks to `ExternalModule` to allow output modules own externals?
 | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | 					/** @type {DependencyMeta | undefined} */ | 
					
						
							|  |  |  | 					let dependencyMeta; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 					if ( | 
					
						
							|  |  |  | 						dependency instanceof HarmonyImportDependency || | 
					
						
							| 
									
										
										
										
											2024-03-16 00:59:30 +08:00
										 |  |  | 						dependency instanceof ImportDependency || | 
					
						
							|  |  |  | 						dependency instanceof ContextElementDependency | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 					) { | 
					
						
							| 
									
										
										
										
											2024-08-03 02:34:51 +08:00
										 |  |  | 						const externalType = | 
					
						
							|  |  |  | 							dependency instanceof HarmonyImportDependency | 
					
						
							|  |  |  | 								? "module" | 
					
						
							|  |  |  | 								: dependency instanceof ImportDependency | 
					
						
							|  |  |  | 									? "import" | 
					
						
							|  |  |  | 									: undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 						dependencyMeta = { | 
					
						
							| 
									
										
										
										
											2024-08-03 02:34:51 +08:00
										 |  |  | 							attributes: dependency.assertions, | 
					
						
							| 
									
										
										
										
											2024-08-19 19:50:35 +08:00
										 |  |  | 							externalType | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 						}; | 
					
						
							|  |  |  | 					} else if (dependency instanceof CssImportDependency) { | 
					
						
							|  |  |  | 						dependencyMeta = { | 
					
						
							|  |  |  | 							layer: dependency.layer, | 
					
						
							|  |  |  | 							supports: dependency.supports, | 
					
						
							|  |  |  | 							media: dependency.media | 
					
						
							|  |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					callback( | 
					
						
							|  |  |  | 						null, | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						new ExternalModule( | 
					
						
							|  |  |  | 							externalConfig, | 
					
						
							| 
									
										
										
										
											2024-08-08 02:59:26 +08:00
										 |  |  | 							/** @type {string} */ | 
					
						
							|  |  |  | 							(type || globalType), | 
					
						
							| 
									
										
										
										
											2024-03-15 20:15:53 +08:00
										 |  |  | 							dependency.request, | 
					
						
							|  |  |  | 							dependencyMeta | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						) | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					); | 
					
						
							|  |  |  | 				}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 				/** | 
					
						
							|  |  |  | 				 * @param {Externals} externals externals config | 
					
						
							| 
									
										
										
										
											2021-12-24 20:27:31 +08:00
										 |  |  | 				 * @param {function((Error | null)=, ExternalModule=): void} callback callback | 
					
						
							| 
									
										
										
										
											2020-05-15 22:24:11 +08:00
										 |  |  | 				 * @returns {void} | 
					
						
							|  |  |  | 				 */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 				const handleExternals = (externals, callback) => { | 
					
						
							|  |  |  | 					if (typeof externals === "string") { | 
					
						
							|  |  |  | 						if (externals === dependency.request) { | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 							return handleExternal(dependency.request, undefined, callback); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} else if (Array.isArray(externals)) { | 
					
						
							|  |  |  | 						let i = 0; | 
					
						
							|  |  |  | 						const next = () => { | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 							/** @type {boolean | undefined} */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							let asyncFlag; | 
					
						
							| 
									
										
										
										
											2024-03-15 22:24:33 +08:00
										 |  |  | 							/** | 
					
						
							|  |  |  | 							 * @param {(Error | null)=} err err | 
					
						
							|  |  |  | 							 * @param {ExternalModule=} module module | 
					
						
							|  |  |  | 							 * @returns {void} | 
					
						
							|  |  |  | 							 */ | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							const handleExternalsAndCallback = (err, module) => { | 
					
						
							|  |  |  | 								if (err) return callback(err); | 
					
						
							|  |  |  | 								if (!module) { | 
					
						
							|  |  |  | 									if (asyncFlag) { | 
					
						
							|  |  |  | 										asyncFlag = false; | 
					
						
							|  |  |  | 										return; | 
					
						
							|  |  |  | 									} | 
					
						
							|  |  |  | 									return next(); | 
					
						
							| 
									
										
										
										
											2016-10-29 17:11:44 +08:00
										 |  |  | 								} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 								callback(null, module); | 
					
						
							|  |  |  | 							}; | 
					
						
							| 
									
										
										
										
											2016-10-29 17:11:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							do { | 
					
						
							|  |  |  | 								asyncFlag = true; | 
					
						
							|  |  |  | 								if (i >= externals.length) return callback(); | 
					
						
							|  |  |  | 								handleExternals(externals[i++], handleExternalsAndCallback); | 
					
						
							| 
									
										
										
										
											2018-06-27 19:48:13 +08:00
										 |  |  | 							} while (!asyncFlag); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							asyncFlag = false; | 
					
						
							|  |  |  | 						}; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						next(); | 
					
						
							|  |  |  | 						return; | 
					
						
							|  |  |  | 					} else if (externals instanceof RegExp) { | 
					
						
							|  |  |  | 						if (externals.test(dependency.request)) { | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 							return handleExternal(dependency.request, undefined, callback); | 
					
						
							| 
									
										
										
										
											2015-05-13 06:15:01 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} else if (typeof externals === "function") { | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						const cb = (err, value, type) => { | 
					
						
							|  |  |  | 							if (err) return callback(err); | 
					
						
							|  |  |  | 							if (value !== undefined) { | 
					
						
							|  |  |  | 								handleExternal(value, type, callback); | 
					
						
							|  |  |  | 							} else { | 
					
						
							|  |  |  | 								callback(); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						}; | 
					
						
							|  |  |  | 						if (externals.length === 3) { | 
					
						
							|  |  |  | 							// TODO webpack 6 remove this
 | 
					
						
							| 
									
										
										
										
											2019-11-15 17:10:26 +08:00
										 |  |  | 							callDeprecatedExternals( | 
					
						
							|  |  |  | 								externals, | 
					
						
							|  |  |  | 								context, | 
					
						
							|  |  |  | 								dependency.request, | 
					
						
							|  |  |  | 								cb | 
					
						
							|  |  |  | 							); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						} else { | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | 							const promise = externals( | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 								{ | 
					
						
							|  |  |  | 									context, | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 									request: dependency.request, | 
					
						
							| 
									
										
										
										
											2021-06-24 22:45:14 +08:00
										 |  |  | 									dependencyType, | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | 									contextInfo, | 
					
						
							|  |  |  | 									getResolve: options => (context, request, callback) => { | 
					
						
							|  |  |  | 										const resolveContext = { | 
					
						
							|  |  |  | 											fileDependencies: data.fileDependencies, | 
					
						
							|  |  |  | 											missingDependencies: data.missingDependencies, | 
					
						
							|  |  |  | 											contextDependencies: data.contextDependencies | 
					
						
							|  |  |  | 										}; | 
					
						
							|  |  |  | 										let resolver = normalModuleFactory.getResolver( | 
					
						
							|  |  |  | 											"normal", | 
					
						
							|  |  |  | 											dependencyType | 
					
						
							|  |  |  | 												? cachedSetProperty( | 
					
						
							|  |  |  | 														data.resolveOptions || EMPTY_RESOLVE_OPTIONS, | 
					
						
							|  |  |  | 														"dependencyType", | 
					
						
							|  |  |  | 														dependencyType | 
					
						
							| 
									
										
										
										
											2024-01-14 09:41:34 +08:00
										 |  |  | 													) | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | 												: data.resolveOptions | 
					
						
							|  |  |  | 										); | 
					
						
							|  |  |  | 										if (options) resolver = resolver.withOptions(options); | 
					
						
							|  |  |  | 										if (callback) { | 
					
						
							|  |  |  | 											resolver.resolve( | 
					
						
							|  |  |  | 												{}, | 
					
						
							|  |  |  | 												context, | 
					
						
							|  |  |  | 												request, | 
					
						
							|  |  |  | 												resolveContext, | 
					
						
							|  |  |  | 												callback | 
					
						
							|  |  |  | 											); | 
					
						
							|  |  |  | 										} else { | 
					
						
							|  |  |  | 											return new Promise((resolve, reject) => { | 
					
						
							|  |  |  | 												resolver.resolve( | 
					
						
							|  |  |  | 													{}, | 
					
						
							|  |  |  | 													context, | 
					
						
							|  |  |  | 													request, | 
					
						
							|  |  |  | 													resolveContext, | 
					
						
							|  |  |  | 													(err, result) => { | 
					
						
							|  |  |  | 														if (err) reject(err); | 
					
						
							|  |  |  | 														else resolve(result); | 
					
						
							|  |  |  | 													} | 
					
						
							|  |  |  | 												); | 
					
						
							|  |  |  | 											}); | 
					
						
							|  |  |  | 										} | 
					
						
							|  |  |  | 									} | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 								}, | 
					
						
							|  |  |  | 								cb | 
					
						
							|  |  |  | 							); | 
					
						
							| 
									
										
										
										
											2021-01-15 20:55:19 +08:00
										 |  |  | 							if (promise && promise.then) promise.then(r => cb(null, r), cb); | 
					
						
							| 
									
										
										
										
											2018-12-21 17:13:20 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 						return; | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 					} else if (typeof externals === "object") { | 
					
						
							| 
									
										
										
										
											2021-01-06 18:14:23 +08:00
										 |  |  | 						const resolvedExternals = resolveLayer( | 
					
						
							|  |  |  | 							externals, | 
					
						
							|  |  |  | 							contextInfo.issuerLayer | 
					
						
							|  |  |  | 						); | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 						if ( | 
					
						
							|  |  |  | 							Object.prototype.hasOwnProperty.call( | 
					
						
							| 
									
										
										
										
											2021-01-06 18:14:23 +08:00
										 |  |  | 								resolvedExternals, | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 								dependency.request | 
					
						
							|  |  |  | 							) | 
					
						
							|  |  |  | 						) { | 
					
						
							|  |  |  | 							return handleExternal( | 
					
						
							| 
									
										
										
										
											2021-01-06 18:14:23 +08:00
										 |  |  | 								resolvedExternals[dependency.request], | 
					
						
							| 
									
										
										
										
											2020-12-22 21:51:09 +08:00
										 |  |  | 								undefined, | 
					
						
							|  |  |  | 								callback | 
					
						
							|  |  |  | 							); | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					callback(); | 
					
						
							|  |  |  | 				}; | 
					
						
							| 
									
										
										
										
											2017-11-08 18:32:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-05 02:17:37 +08:00
										 |  |  | 				handleExternals(this.externals, callback); | 
					
						
							| 
									
										
										
										
											2018-02-25 09:00:20 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-02-23 23:00:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = ExternalModuleFactoryPlugin; |