From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送

---
 node_modules/webpack/lib/ExternalModuleFactoryPlugin.js |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js b/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
index b2f8683..dde9b80 100644
--- a/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
+++ b/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
@@ -17,20 +17,23 @@
 /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
 /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
 /** @typedef {import("../declarations/WebpackOptions").ExternalsType} ExternalsType */
+/** @typedef {import("../declarations/WebpackOptions").ExternalItem} ExternalItem */
 /** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */
 /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
 /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
 /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
+/** @typedef {import("./Dependency")} Dependency */
 /** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */
 /** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */
 /** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
 /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
 
-/** @typedef {((context: string, request: string, callback: (err?: Error | null, result?: string | false, resolveRequest?: import('enhanced-resolve').ResolveRequest) => void) => void)} ExternalItemFunctionDataGetResolveCallbackResult */
+/** @typedef {((context: string, request: string, callback: (err?: Error | null, result?: string | false, resolveRequest?: import("enhanced-resolve").ResolveRequest) => void) => void)} ExternalItemFunctionDataGetResolveCallbackResult */
 /** @typedef {((context: string, request: string) => Promise<string>)} ExternalItemFunctionDataGetResolveResult */
 /** @typedef {(options?: ResolveOptions) => ExternalItemFunctionDataGetResolveCallbackResult | ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolve */
 
 /**
+ * Defines the external item function data type used by this module.
  * @typedef {object} ExternalItemFunctionData
  * @property {string} context the directory in which the request is placed
  * @property {ModuleFactoryCreateDataContextInfo} contextInfo contextual information
@@ -48,6 +51,7 @@
 // TODO webpack 6 remove this
 const callDeprecatedExternals = util.deprecate(
 	/**
+	 * Handles the callback logic for this hook.
 	 * @param {EXPECTED_FUNCTION} externalsFunction externals function
 	 * @param {string} context context
 	 * @param {string} request request
@@ -61,9 +65,11 @@
 	"DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS"
 );
 
+/** @typedef {(layer: string | null) => ExternalItem} ExternalItemByLayerFn */
 /** @typedef {ExternalItemObjectKnown & ExternalItemObjectUnknown} ExternalItemObject */
 
 /**
+ * Defines the external weak cache type used by this module.
  * @template {ExternalItemObject} T
  * @typedef {WeakMap<T, Map<IssuerLayer, Omit<T, "byLayer">>>} ExternalWeakCache
  */
@@ -72,6 +78,7 @@
 const cache = new WeakMap();
 
 /**
+ * Returns result.
  * @param {ExternalItemObject} obj obj
  * @param {IssuerLayer} layer layer
  * @returns {Omit<ExternalItemObject, "byLayer">} result
@@ -96,7 +103,8 @@
 
 class ExternalModuleFactoryPlugin {
 	/**
-	 * @param {ExternalsType} type default external type
+	 * Creates an instance of ExternalModuleFactoryPlugin.
+	 * @param {ExternalsType | ((dependency: Dependency) => ExternalsType)} type default external type
 	 * @param {Externals} externals externals config
 	 */
 	constructor(type, externals) {
@@ -105,6 +113,7 @@
 	}
 
 	/**
+	 * Applies the plugin by registering its hooks on the compiler.
 	 * @param {NormalModuleFactory} normalModuleFactory the normal module factory
 	 * @returns {void}
 	 */
@@ -121,6 +130,7 @@
 				/** @typedef {(err?: Error | null, externalModule?: ExternalModule) => void} HandleExternalCallback */
 
 				/**
+				 * Processes the provided value.
 				 * @param {ExternalValue} value the external config
 				 * @param {ExternalsType | undefined} type type of external
 				 * @param {HandleExternalCallback} callback callback
@@ -159,7 +169,11 @@
 						}
 					}
 
-					const resolvedType = type || globalType;
+					const defaultType =
+						typeof globalType === "function"
+							? globalType(dependency)
+							: globalType;
+					const resolvedType = type || defaultType;
 
 					// TODO make it pluggable/add hooks to `ExternalModule` to allow output modules own externals?
 					/** @type {DependencyMeta | undefined} */
@@ -208,6 +222,7 @@
 				};
 
 				/**
+				 * Processes the provided external.
 				 * @param {Externals} externals externals config
 				 * @param {HandleExternalCallback} callback callback
 				 * @returns {void}
@@ -223,6 +238,7 @@
 							/** @type {boolean | undefined} */
 							let asyncFlag;
 							/**
+							 * Handle externals and callback.
 							 * @param {(Error | null)=} err err
 							 * @param {ExternalModule=} module module
 							 * @returns {void}
@@ -255,6 +271,7 @@
 						}
 					} else if (typeof externals === "function") {
 						/**
+						 * Processes the provided err.
 						 * @param {Error | null | undefined} err err
 						 * @param {ExternalValue=} value value
 						 * @param {ExternalsType=} type type

--
Gitblit v1.9.3