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/node/NodeTargetPlugin.js |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/node_modules/webpack/lib/node/NodeTargetPlugin.js b/node_modules/webpack/lib/node/NodeTargetPlugin.js
index 28ab03a..c595cd9 100644
--- a/node_modules/webpack/lib/node/NodeTargetPlugin.js
+++ b/node_modules/webpack/lib/node/NodeTargetPlugin.js
@@ -74,19 +74,29 @@
 
 class NodeTargetPlugin {
 	/**
+	 * Creates an instance of NodeTargetPlugin.
 	 * @param {ExternalsType} type default external type
 	 */
 	constructor(type = "node-commonjs") {
+		/** @type {ExternalsType} */
 		this.type = type;
 	}
 
 	/**
-	 * Apply the plugin
+	 * Applies the plugin by registering its hooks on the compiler.
 	 * @param {Compiler} compiler the compiler instance
 	 * @returns {void}
 	 */
 	apply(compiler) {
-		new ExternalsPlugin(this.type, builtins).apply(compiler);
+		new ExternalsPlugin((dependency) => {
+			// When `require` node.js built-in modules with module output
+			// we should still emit `createRequire` for compatibility
+			if (dependency.category === "commonjs") {
+				return "node-commonjs";
+			}
+
+			return this.type;
+		}, builtins).apply(compiler);
 	}
 }
 

--
Gitblit v1.9.3