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/buildChunkGraph.js |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/node_modules/webpack/lib/buildChunkGraph.js b/node_modules/webpack/lib/buildChunkGraph.js
index 04cb775..e7cb858 100644
--- a/node_modules/webpack/lib/buildChunkGraph.js
+++ b/node_modules/webpack/lib/buildChunkGraph.js
@@ -24,6 +24,7 @@
 /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
 
 /**
+ * Defines the queue item type used by this module.
  * @typedef {object} QueueItem
  * @property {number} action
  * @property {DependenciesBlock} block
@@ -34,6 +35,7 @@
  */
 
 /**
+ * Defines the chunk group info type used by this module.
  * @typedef {object} ChunkGroupInfo
  * @property {ChunkGroup} chunkGroup the chunk group
  * @property {RuntimeSpec} runtime the runtimes
@@ -50,9 +52,12 @@
  * @property {number} postOrderIndex next post order index
  * @property {boolean} chunkLoading has a chunk loading mechanism
  * @property {boolean} asyncChunks create async chunks
+ * @property {Module | null} depModule the module that is the dependency of the block
+ * @property {boolean} circular Whether to deduplicate to avoid circular references
  */
 
 /**
+ * Defines the block chunk group connection type used by this module.
  * @typedef {object} BlockChunkGroupConnection
  * @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group
  * @property {ChunkGroup} chunkGroup referenced chunk group
@@ -72,6 +77,7 @@
 const ONE_BIGINT = BigInt(1);
 
 /**
+ * Checks whether this object is ordinal set in mask.
  * @param {bigint} mask The mask to test
  * @param {number} ordinal The ordinal of the bit to test
  * @returns {boolean} If the ordinal-th bit is set in the mask
@@ -80,6 +86,7 @@
 	BigInt.asUintN(1, mask >> BigInt(ordinal)) !== ZERO_BIGINT;
 
 /**
+ * Gets active state of connections.
  * @param {ModuleGraphConnection[]} connections list of connections
  * @param {RuntimeSpec} runtime for which runtime
  * @returns {ConnectionState} connection state
@@ -99,6 +106,7 @@
 };
 
 /**
+ * Extract block modules.
  * @param {Module} module module
  * @param {ModuleGraph} moduleGraph module graph
  * @param {RuntimeSpec} runtime runtime
@@ -165,6 +173,7 @@
 
 	for (const modules of arrays) {
 		if (modules.length === 0) continue;
+		/** @type {undefined | Map<Module | ModuleGraphConnection | ConnectionState, number>} */
 		let indexMap;
 		let length = 0;
 		outer: for (let j = 0; j < modules.length; j += 3) {
@@ -234,6 +243,7 @@
 };
 
 /**
+ * Processes the provided logger.
  * @param {Logger} logger a logger
  * @param {Compilation} compilation the compilation
  * @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules
@@ -265,6 +275,7 @@
 	const ordinalByModule = new Map();
 
 	/**
+	 * Gets module ordinal.
 	 * @param {Module} module The module to look up
 	 * @returns {number} The ordinal of the module in masks
 	 */
@@ -286,6 +297,7 @@
 	}
 
 	/**
+	 * Gets block modules.
 	 * @param {DependenciesBlock} block block
 	 * @param {RuntimeSpec} runtime runtime
 	 * @returns {BlockModulesInFlattenTuples | undefined} block modules in flatten tuples
@@ -352,11 +364,16 @@
 	/** @type {Map<ChunkGroupInfo, Set<DependenciesBlock>>} */
 	const blocksByChunkGroups = new Map();
 
-	/** @type {Map<string, ChunkGroupInfo>} */
+	/** @typedef {Map<string, ChunkGroupInfo>} NamedChunkGroup */
+
+	/** @type {NamedChunkGroup} */
 	const namedChunkGroups = new Map();
 
-	/** @type {Map<string, ChunkGroupInfo>} */
+	/** @type {NamedChunkGroup} */
 	const namedAsyncEntrypoints = new Map();
+
+	/** @type {Map<Module, ChunkGroupInfo>} */
+	const depModuleAsyncEntrypoints = new Map();
 
 	/** @type {Set<ChunkGroupInfo>} */
 	const outdatedOrderIndexChunkGroups = new Set();
@@ -371,7 +388,8 @@
 	/** @type {QueueItem[]} */
 	let queue = [];
 
-	/** @type {Map<ChunkGroupInfo, Set<[ChunkGroupInfo, QueueItem | null]>>} */
+	/** @typedef {Set<[ChunkGroupInfo, QueueItem | null]>} ConnectList */
+	/** @type {Map<ChunkGroupInfo, ConnectList>} */
 	const queueConnect = new Map();
 	/** @type {Set<ChunkGroupInfo>} */
 	const chunkGroupsForCombining = new Set();
@@ -386,6 +404,8 @@
 		);
 		/** @type {ChunkGroupInfo} */
 		const chunkGroupInfo = {
+			depModule: null,
+			circular: false,
 			initialized: false,
 			chunkGroup,
 			runtime,
@@ -482,6 +502,7 @@
 
 	// For each async Block in graph
 	/**
+	 * Processes the provided b.
 	 * @param {AsyncDependenciesBlock} b iterating over each Async DepBlock
 	 * @returns {void}
 	 */
@@ -494,11 +515,16 @@
 		let c;
 		/** @type {Entrypoint | undefined} */
 		let entrypoint;
+		/** @type {Module | null} */
+		const depModule = moduleGraph.getModule(b.dependencies[0]);
 		const entryOptions = b.groupOptions && b.groupOptions.entryOptions;
 		if (cgi === undefined) {
 			const chunkName = (b.groupOptions && b.groupOptions.name) || b.chunkName;
 			if (entryOptions) {
 				cgi = namedAsyncEntrypoints.get(/** @type {string} */ (chunkName));
+				if (!cgi && !b.circular && depModule) {
+					cgi = depModuleAsyncEntrypoints.get(depModule);
+				}
 				if (!cgi) {
 					entrypoint = compilation.addAsyncEntrypoint(
 						entryOptions,
@@ -509,6 +535,8 @@
 					maskByChunk.set(entrypoint.chunks[0], ZERO_BIGINT);
 					entrypoint.index = nextChunkGroupIndex++;
 					cgi = {
+						depModule,
+						circular: b.circular,
 						chunkGroup: entrypoint,
 						initialized: false,
 						runtime:
@@ -544,6 +572,12 @@
 							chunkName,
 							/** @type {ChunkGroupInfo} */
 							(cgi)
+						);
+					}
+					if (!b.circular && depModule) {
+						depModuleAsyncEntrypoints.set(
+							depModule,
+							/** @type {ChunkGroupInfo} */ (cgi)
 						);
 					}
 				} else {
@@ -588,6 +622,8 @@
 					maskByChunk.set(c.chunks[0], ZERO_BIGINT);
 					c.index = nextChunkGroupIndex++;
 					cgi = {
+						depModule,
+						circular: b.circular,
 						initialized: false,
 						chunkGroup: c,
 						runtime: chunkGroupInfo.runtime,
@@ -649,6 +685,7 @@
 			// 3. We enqueue the chunk group info creation/updating
 			let connectList = queueConnect.get(chunkGroupInfo);
 			if (connectList === undefined) {
+				/** @type {ConnectList} */
 				connectList = new Set();
 				queueConnect.set(chunkGroupInfo, connectList);
 			}
@@ -663,12 +700,16 @@
 					chunkGroupInfo: /** @type {ChunkGroupInfo} */ (cgi)
 				}
 			]);
-		} else if (entrypoint !== undefined) {
+		} else if (
+			entrypoint !== undefined &&
+			(chunkGroupInfo.circular || chunkGroupInfo.depModule !== depModule)
+		) {
 			chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint);
 		}
 	};
 
 	/**
+	 * Processes the provided block.
 	 * @param {DependenciesBlock} block the block
 	 * @returns {void}
 	 */
@@ -761,6 +802,7 @@
 	};
 
 	/**
+	 * Process entry block.
 	 * @param {DependenciesBlock} block the block
 	 * @returns {void}
 	 */
@@ -888,6 +930,7 @@
 	};
 
 	/**
+	 * Calculate resulting available modules.
 	 * @param {ChunkGroupInfo} chunkGroupInfo The info object for the chunk group
 	 * @returns {bigint} The mask of available modules after the chunk group
 	 */
@@ -1089,6 +1132,7 @@
 				for (const cgi of info.children) {
 					let connectList = queueConnect.get(info);
 					if (connectList === undefined) {
+						/** @type {ConnectList} */
 						connectList = new Set();
 						queueConnect.set(info, connectList);
 					}
@@ -1162,6 +1206,7 @@
 			let preOrderIndex = 0;
 			let postOrderIndex = 0;
 			/**
+			 * Processes the provided current.
 			 * @param {DependenciesBlock} current current
 			 * @param {BlocksWithNestedBlocks} visited visited dependencies blocks
 			 */
@@ -1209,6 +1254,7 @@
 };
 
 /**
+ * Connects chunk groups.
  * @param {Compilation} compilation the compilation
  * @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks
  * @param {BlockConnections} blockConnections connection for blocks

--
Gitblit v1.9.3