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/watchpack/lib/reducePlan.js | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/node_modules/watchpack/lib/reducePlan.js b/node_modules/watchpack/lib/reducePlan.js
index b281ed6..a6ced7f 100644
--- a/node_modules/watchpack/lib/reducePlan.js
+++ b/node_modules/watchpack/lib/reducePlan.js
@@ -8,48 +8,48 @@
/**
* @template T
- * @typedef {Object} TreeNode
- * @property {string} filePath
- * @property {TreeNode} parent
- * @property {TreeNode[]} children
- * @property {number} entries
- * @property {boolean} active
- * @property {T[] | T | undefined} value
+ * @typedef {object} TreeNode
+ * @property {string} target target
+ * @property {TreeNode<T>} parent parent
+ * @property {TreeNode<T>[]} children children
+ * @property {number} entries number of entries
+ * @property {boolean} active true when active, otherwise false
+ * @property {T[] | T | undefined} value value
*/
/**
* @template T
- * @param {Map<string, T[] | T} plan
- * @param {number} limit
+ * @param {Map<string, T[] | T>} plan plan
+ * @param {number} limit limit
* @returns {Map<string, Map<T, string>>} the new plan
*/
module.exports = (plan, limit) => {
const treeMap = new Map();
// Convert to tree
- for (const [filePath, value] of plan) {
- treeMap.set(filePath, {
- filePath,
+ for (const [target, value] of plan) {
+ treeMap.set(target, {
+ target,
parent: undefined,
children: undefined,
entries: 1,
active: true,
- value
+ value,
});
}
let currentCount = treeMap.size;
// Create parents and calculate sum of entries
for (const node of treeMap.values()) {
- const parentPath = path.dirname(node.filePath);
- if (parentPath !== node.filePath) {
+ const parentPath = path.dirname(node.target);
+ if (parentPath !== node.target) {
let parent = treeMap.get(parentPath);
if (parent === undefined) {
parent = {
- filePath: parentPath,
+ target: parentPath,
parent: undefined,
children: [node],
entries: node.entries,
active: false,
- value: undefined
+ value: undefined,
};
treeMap.set(parentPath, parent);
node.parent = parent;
@@ -71,7 +71,7 @@
while (currentCount > limit) {
// Select node that helps reaching the limit most effectively without overmerging
const overLimit = currentCount - limit;
- let bestNode = undefined;
+ let bestNode;
let bestCost = Infinity;
for (const node of treeMap.values()) {
if (node.entries <= 1 || !node.children || !node.parent) continue;
@@ -95,7 +95,7 @@
bestNode.active = true;
bestNode.entries = 1;
currentCount -= reduction;
- let parent = bestNode.parent;
+ let { parent } = bestNode;
while (parent) {
parent.entries -= reduction;
parent = parent.parent;
@@ -120,10 +120,10 @@
if (node.value) {
if (Array.isArray(node.value)) {
for (const item of node.value) {
- map.set(item, node.filePath);
+ map.set(item, node.target);
}
} else {
- map.set(node.value, node.filePath);
+ map.set(node.value, node.target);
}
}
if (node.children) {
@@ -132,7 +132,7 @@
}
}
}
- newPlan.set(rootNode.filePath, map);
+ newPlan.set(rootNode.target, map);
}
return newPlan;
};
--
Gitblit v1.9.3