From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试

---
 node_modules/webpack/lib/CompatibilityPlugin.js |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/node_modules/webpack/lib/CompatibilityPlugin.js b/node_modules/webpack/lib/CompatibilityPlugin.js
index 05f3924..d3e681e 100644
--- a/node_modules/webpack/lib/CompatibilityPlugin.js
+++ b/node_modules/webpack/lib/CompatibilityPlugin.js
@@ -21,6 +21,8 @@
 /** @typedef {import("./javascript/JavascriptParser").Range} Range */
 
 /**
+ * Captures the source range of a renamed compatibility binding so it can be
+ * rewritten exactly once.
  * @typedef {object} CompatibilitySettingsDeclaration
  * @property {boolean} updated
  * @property {DependencyLocation} loc
@@ -28,6 +30,8 @@
  */
 
 /**
+ * Stores the replacement variable name and the declaration metadata tracked
+ * for a compatibility rewrite.
  * @typedef {object} CompatibilitySettings
  * @property {string} name
  * @property {CompatibilitySettingsDeclaration} declaration
@@ -36,9 +40,14 @@
 const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
 const PLUGIN_NAME = "CompatibilityPlugin";
 
+/**
+ * Adds parser-time compatibility rewrites for legacy runtime patterns that
+ * webpack still needs to recognize in user and generated code.
+ */
 class CompatibilityPlugin {
 	/**
-	 * Apply the plugin
+	 * Installs parser hooks that preserve compatibility with legacy patterns
+	 * such as nested `__webpack_require__` bindings and hashbang handling.
 	 * @param {Compiler} compiler the compiler instance
 	 * @returns {void}
 	 */
@@ -64,6 +73,9 @@
 						parser.hooks.call.for("require").tap(
 							PLUGIN_NAME,
 							/**
+							 * Rewrites browserify-style delegated `require` calls into a
+							 * plain webpack require reference and removes the synthetic
+							 * context dependency created for the delegator pattern.
 							 * @param {CallExpression} expr call expression
 							 * @returns {boolean | void} true when need to handle
 							 */
@@ -103,6 +115,8 @@
 					});
 
 				/**
+				 * Attaches the compatibility rewrites for a JavaScript parser
+				 * instance.
 				 * @param {JavascriptParser} parser the parser
 				 * @returns {void}
 				 */
@@ -147,6 +161,9 @@
 									range: /** @type {Range} */ (pattern.range)
 								}
 							});
+							if (parser.scope.topLevelScope !== true) {
+								return true;
+							}
 						});
 					parser.hooks.pattern
 						.for(RuntimeGlobals.exports)

--
Gitblit v1.9.3