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/json/JsonParser.js |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/node_modules/webpack/lib/json/JsonParser.js b/node_modules/webpack/lib/json/JsonParser.js
index cdb4d9c..c757773 100644
--- a/node_modules/webpack/lib/json/JsonParser.js
+++ b/node_modules/webpack/lib/json/JsonParser.js
@@ -7,7 +7,7 @@
 
 const Parser = require("../Parser");
 const JsonExportsDependency = require("../dependencies/JsonExportsDependency");
-const memoize = require("../util/memoize");
+const parseJson = require("../util/parseJson");
 const JsonData = require("./JsonData");
 
 /** @typedef {import("../../declarations/plugins/JsonModulesPluginParser").JsonModulesPluginParserOptions} JsonModulesPluginParserOptions */
@@ -19,18 +19,25 @@
 
 /** @typedef {(input: string) => Buffer | JsonValue} ParseFn */
 
-const getParseJson = memoize(() => require("json-parse-even-better-errors"));
+/**
+ * Defines the function returning type used by this module.
+ * @template T
+ * @typedef {import("../util/memoize").FunctionReturning<T>} FunctionReturning
+ */
 
 class JsonParser extends Parser {
 	/**
+	 * Creates an instance of JsonParser.
 	 * @param {JsonModulesPluginParserOptions} options parser options
 	 */
-	constructor(options) {
+	constructor(options = {}) {
 		super();
-		this.options = options || {};
+		/** @type {JsonModulesPluginParserOptions} */
+		this.options = options;
 	}
 
 	/**
+	 * Parses the provided source and updates the parser state.
 	 * @param {string | Buffer | PreparsedAst} source the source to parse
 	 * @param {ParserState} state the parser state
 	 * @returns {ParserState} the parser state
@@ -40,11 +47,9 @@
 			source = source.toString("utf8");
 		}
 
-		/** @type {ParseFn} */
+		/** @type {typeof parseJson} */
 		const parseFn =
-			typeof this.options.parse === "function"
-				? this.options.parse
-				: getParseJson();
+			typeof this.options.parse === "function" ? this.options.parse : parseJson;
 		/** @type {Buffer | JsonValue | undefined} */
 		let data;
 		try {
@@ -54,7 +59,8 @@
 					: parseFn(source[0] === "\uFEFF" ? source.slice(1) : source);
 		} catch (err) {
 			throw new Error(
-				`Cannot parse JSON: ${/** @type {Error} */ (err).message}`
+				`Cannot parse JSON: ${/** @type {Error} */ (err).message}`,
+				{ cause: err }
 			);
 		}
 		const jsonData = new JsonData(/** @type {Buffer | JsonValue} */ (data));

--
Gitblit v1.9.3