From 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 四月 2026 11:46:41 +0800
Subject: [PATCH] 推送

---
 node_modules/webpack/lib/Template.js |   60 ++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/node_modules/webpack/lib/Template.js b/node_modules/webpack/lib/Template.js
index 99a4af2..0a36116 100644
--- a/node_modules/webpack/lib/Template.js
+++ b/node_modules/webpack/lib/Template.js
@@ -36,13 +36,14 @@
 const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
 const INDENT_MULTILINE_REGEX = /^\t/gm;
 const LINE_SEPARATOR_REGEX = /\r?\n/g;
-const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/;
-const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
+const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-z$_])/i;
+const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-z0-9$]+/gi;
 const COMMENT_END_REGEX = /\*\//g;
-const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!搂$()=\-^掳]+/g;
+const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-z0-9_!搂$()=\-^掳]+/gi;
 const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
 
 /**
+ * Defines the render manifest options type used by this module.
  * @typedef {object} RenderManifestOptions
  * @property {Chunk} chunk the chunk used to render
  * @property {string} hash
@@ -59,6 +60,7 @@
 /** @typedef {RenderManifestEntryTemplated | RenderManifestEntryStatic} RenderManifestEntry */
 
 /**
+ * Defines the render manifest entry templated type used by this module.
  * @typedef {object} RenderManifestEntryTemplated
  * @property {() => Source} render
  * @property {TemplatePath} filenameTemplate
@@ -70,6 +72,7 @@
  */
 
 /**
+ * Defines the render manifest entry static type used by this module.
  * @typedef {object} RenderManifestEntryStatic
  * @property {() => Source} render
  * @property {string} filename
@@ -80,13 +83,20 @@
  */
 
 /**
+ * Defines the module filter predicate type used by this module.
  * @typedef {(module: Module) => boolean} ModuleFilterPredicate
+ */
+
+/**
+ * Represents the template runtime component.
+ * @typedef {object} Stringable
+ * @property {() => string} toString
  */
 
 class Template {
 	/**
-	 * @template {EXPECTED_FUNCTION} T
-	 * @param {T} fn a runtime function (.runtime.js) "template"
+	 * Gets function content.
+	 * @param {Stringable} fn a runtime function (.runtime.js) "template"
 	 * @returns {string} the updated and normalized function string
 	 */
 	static getFunctionContent(fn) {
@@ -98,6 +108,7 @@
 	}
 
 	/**
+	 * Returns created identifier.
 	 * @param {string} str the string converted to identifier
 	 * @returns {string} created identifier
 	 */
@@ -109,6 +120,7 @@
 	}
 
 	/**
+	 * Returns a commented version of string.
 	 * @param {string} str string to be converted to commented in bundle code
 	 * @returns {string} returns a commented version of string
 	 */
@@ -118,6 +130,7 @@
 	}
 
 	/**
+	 * Returns a commented version of string.
 	 * @param {string} str string to be converted to "normal comment"
 	 * @returns {string} returns a commented version of string
 	 */
@@ -127,6 +140,7 @@
 	}
 
 	/**
+	 * Returns normalized bundle-safe path.
 	 * @param {string} str string path to be normalized
 	 * @returns {string} normalized bundle-safe path
 	 */
@@ -139,6 +153,7 @@
 
 	// map number to a single character a-z, A-Z or multiple characters if number is too big
 	/**
+	 * Number to identifier.
 	 * @param {number} n number to convert to ident
 	 * @returns {string} returns single character ident
 	 */
@@ -169,6 +184,7 @@
 	}
 
 	/**
+	 * Number to identifier continuation.
 	 * @param {number} n number to convert to ident
 	 * @returns {string} returns single character ident
 	 */
@@ -207,6 +223,7 @@
 	}
 
 	/**
+	 * Returns converted identity.
 	 * @param {string | string[]} s string to convert to identity
 	 * @returns {string} converted identity
 	 */
@@ -221,6 +238,7 @@
 	}
 
 	/**
+	 * Returns new prefix string.
 	 * @param {string | string[]} s string to create prefix for
 	 * @param {string} prefix prefix to compose
 	 * @returns {string} returns new prefix string
@@ -233,6 +251,7 @@
 	}
 
 	/**
+	 * Returns a single string from array.
 	 * @param {string | string[]} str string or string collection
 	 * @returns {string} returns a single string from array
 	 */
@@ -244,11 +263,13 @@
 	}
 
 	/**
+	 * Defines the with id type used by this module.
 	 * @typedef {object} WithId
 	 * @property {string | number} id
 	 */
 
 	/**
+	 * Gets modules array bounds.
 	 * @param {WithId[]} modules a collection of modules to get array bounds for
 	 * @returns {[number, number] | false} returns the upper and lower array bounds
 	 * or false if not every module has a number based id
@@ -278,9 +299,10 @@
 	}
 
 	/**
+	 * Renders chunk modules.
 	 * @param {ChunkRenderContext} renderContext render context
 	 * @param {Module[]} modules modules to render (should be ordered by identifier)
-	 * @param {(module: Module) => Source | null} renderModule function to render a module
+	 * @param {(module: Module, renderInArray?: boolean) => Source | null} renderModule function to render a module
 	 * @param {string=} prefix applying prefix strings
 	 * @returns {Source | null} rendered chunk modules in a Source object or null if no modules
 	 */
@@ -290,12 +312,20 @@
 		if (modules.length === 0) {
 			return null;
 		}
-		/** @type {{ id: ModuleId, source: Source | "false" }[]} */
-		const allModules = modules.map((module) => ({
-			id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)),
-			source: renderModule(module) || "false"
+		/** @type {{ id: ModuleId, module: Module }[]} */
+		const modulesWithId = modules.map((m) => ({
+			id: /** @type {ModuleId} */ (chunkGraph.getModuleId(m)),
+			module: m
 		}));
-		const bounds = Template.getModulesArrayBounds(allModules);
+		const bounds = Template.getModulesArrayBounds(modulesWithId);
+		const renderInObject = bounds === false;
+
+		/** @type {{ id: ModuleId, source: Source | "false" }[]} */
+		const allModules = modulesWithId.map(({ id, module }) => ({
+			id,
+			source: renderModule(module, renderInObject) || "false"
+		}));
+
 		if (bounds) {
 			// Render a spare array
 			const minId = bounds[0];
@@ -332,7 +362,9 @@
 				if (i !== 0) {
 					source.add(",\n");
 				}
-				source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
+				source.add(
+					`\n/***/ ${JSON.stringify(module.id)}${renderContext.runtimeTemplate.supportsMethodShorthand() && module.source !== "false" ? "" : ":"}\n`
+				);
 				source.add(module.source);
 			}
 			source.add(`\n\n${prefix}}`);
@@ -341,6 +373,7 @@
 	}
 
 	/**
+	 * Renders runtime modules.
 	 * @param {RuntimeModule[]} runtimeModules array of runtime modules in order
 	 * @param {RenderContext & { codeGenerationResults?: CodeGenerationResults }} renderContext render context
 	 * @returns {Source} rendered runtime modules in a Source object
@@ -349,6 +382,7 @@
 		const source = new ConcatSource();
 		for (const module of runtimeModules) {
 			const codeGenerationResults = renderContext.codeGenerationResults;
+			/** @type {undefined | Source} */
 			let runtimeSource;
 			if (codeGenerationResults) {
 				runtimeSource = codeGenerationResults.getSource(
@@ -363,6 +397,7 @@
 					moduleGraph: renderContext.moduleGraph,
 					runtimeTemplate: renderContext.runtimeTemplate,
 					runtime: renderContext.chunk.runtime,
+					runtimes: [renderContext.chunk.runtime],
 					codeGenerationResults
 				});
 				if (!codeGenResult) continue;
@@ -388,6 +423,7 @@
 	}
 
 	/**
+	 * Renders chunk runtime modules.
 	 * @param {RuntimeModule[]} runtimeModules array of runtime modules in order
 	 * @param {RenderContext} renderContext render context
 	 * @returns {Source} rendered chunk runtime modules in a Source object

--
Gitblit v1.9.3