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/JsonGenerator.js | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/node_modules/webpack/lib/json/JsonGenerator.js b/node_modules/webpack/lib/json/JsonGenerator.js
index 40ea929..da978a9 100644
--- a/node_modules/webpack/lib/json/JsonGenerator.js
+++ b/node_modules/webpack/lib/json/JsonGenerator.js
@@ -9,14 +9,17 @@
const ConcatenationScope = require("../ConcatenationScope");
const { UsageState } = require("../ExportsInfo");
const Generator = require("../Generator");
-const { JS_TYPES } = require("../ModuleSourceTypesConstants");
+const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
/** @typedef {import("../ExportsInfo")} ExportsInfo */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
+/** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
+/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
+/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */
/** @typedef {import("../NormalModule")} NormalModule */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
@@ -25,8 +28,9 @@
/** @typedef {import("../util/fs").JsonValue} JsonValue */
/**
+ * Returns stringified data.
* @param {JsonValue} data Raw JSON data
- * @returns {undefined|string} stringified data
+ * @returns {undefined | string} stringified data
*/
const stringifySafe = (data) => {
const stringified = JSON.stringify(data);
@@ -40,6 +44,7 @@
};
/**
+ * Creates an object for exports info.
* @param {JsonObject | JsonArray} data Raw JSON data (always an object or array)
* @param {ExportsInfo} exportsInfo exports info
* @param {RuntimeSpec} runtime the runtime
@@ -120,24 +125,28 @@
class JsonGenerator extends Generator {
/**
+ * Creates an instance of JsonGenerator.
* @param {JsonGeneratorOptions} options options
*/
constructor(options) {
super();
+ /** @type {JsonGeneratorOptions} */
this.options = options;
}
/**
+ * Returns the source types available for this module.
* @param {NormalModule} module fresh module
* @returns {SourceTypes} available types (do not mutate)
*/
getTypes(module) {
- return JS_TYPES;
+ return JAVASCRIPT_TYPES;
}
/**
+ * Returns the estimated size for the requested source type.
* @param {NormalModule} module the module
- * @param {string=} type source type
+ * @param {SourceType=} type source type
* @returns {number} estimate size of the module
*/
getSize(module, type) {
@@ -151,6 +160,7 @@
}
/**
+ * Returns the reason this module cannot be concatenated, when one exists.
* @param {NormalModule} module module for which the bailout reason should be determined
* @param {ConcatenationBailoutReasonContext} context context
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
@@ -160,6 +170,7 @@
}
/**
+ * Generates generated code for this runtime module.
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
@@ -219,6 +230,7 @@
}
/**
+ * Generates fallback output for the provided error condition.
* @param {Error} error the error
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
@@ -227,6 +239,17 @@
generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
}
+
+ /**
+ * Updates the hash with the data contributed by this instance.
+ * @param {Hash} hash hash that will be modified
+ * @param {UpdateHashContext} updateHashContext context for updating hash
+ */
+ updateHash(hash, updateHashContext) {
+ if (this.options.JSONParse) {
+ hash.update("json-parse");
+ }
+ }
}
module.exports = JsonGenerator;
--
Gitblit v1.9.3