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/optimize/MangleExportsPlugin.js | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/node_modules/webpack/lib/optimize/MangleExportsPlugin.js b/node_modules/webpack/lib/optimize/MangleExportsPlugin.js
index 39383da..e4e0989 100644
--- a/node_modules/webpack/lib/optimize/MangleExportsPlugin.js
+++ b/node_modules/webpack/lib/optimize/MangleExportsPlugin.js
@@ -17,8 +17,16 @@
/** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../ExportsInfo")} ExportsInfo */
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
+/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
/**
+ * Defines the comparator type used by this module.
+ * @template T
+ * @typedef {import("../util/comparators").Comparator<T>} Comparator
+ */
+
+/**
+ * Checks whether it can mangle.
* @param {ExportsInfo} exportsInfo exports info
* @returns {boolean} mangle is possible
*/
@@ -36,8 +44,10 @@
};
// Sort by name
+/** @type {Comparator<ExportInfo>} */
const comparator = compareSelect((e) => e.name, compareStringsNumeric);
/**
+ * Mangle exports info.
* @param {boolean} deterministic use deterministic names
* @param {ExportsInfo} exportsInfo exports info
* @param {boolean | undefined} isNamespace is namespace object
@@ -45,6 +55,7 @@
*/
const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
if (!canMangle(exportsInfo)) return;
+ /** @type {UsedNames} */
const usedNames = new Set();
/** @type {ExportInfo[]} */
const mangleableExports = [];
@@ -69,11 +80,11 @@
// Can the export be mangled?
exportInfo.canMangle !== true ||
// Never rename 1 char exports
- (name.length === 1 && /^[a-zA-Z0-9_$]/.test(name)) ||
+ (name.length === 1 && /^[a-z0-9_$]/i.test(name)) ||
// Don't rename 2 char exports in deterministic mode
(deterministic &&
name.length === 2 &&
- /^[a-zA-Z_$][a-zA-Z0-9_$]|^[1-9][0-9]/.test(name)) ||
+ /^[a-z_$][a-z0-9_$]|^[1-9][0-9]/i.test(name)) ||
// Don't rename exports that are not provided
(avoidMangleNonProvided && exportInfo.provided !== true)
) {
@@ -119,7 +130,9 @@
usedNames.size
);
} else {
+ /** @type {ExportInfo[]} */
const usedExports = [];
+ /** @type {ExportInfo[]} */
const unusedExports = [];
for (const exportInfo of mangleableExports) {
if (exportInfo.getUsed(undefined) === UsageState.Unused) {
@@ -133,6 +146,7 @@
let i = 0;
for (const list of [usedExports, unusedExports]) {
for (const exportInfo of list) {
+ /** @type {string} */
let name;
do {
name = numberToIdentifier(i++);
@@ -147,14 +161,16 @@
class MangleExportsPlugin {
/**
+ * Creates an instance of MangleExportsPlugin.
* @param {boolean} deterministic use deterministic names
*/
constructor(deterministic) {
+ /** @type {boolean} */
this._deterministic = deterministic;
}
/**
- * Apply the plugin
+ * Applies the plugin by registering its hooks on the compiler.
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
--
Gitblit v1.9.3