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/MultiCompiler.js | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/node_modules/webpack/lib/MultiCompiler.js b/node_modules/webpack/lib/MultiCompiler.js
index 87c61c3..d7cc70a 100644
--- a/node_modules/webpack/lib/MultiCompiler.js
+++ b/node_modules/webpack/lib/MultiCompiler.js
@@ -15,10 +15,12 @@
const ArrayQueue = require("./util/ArrayQueue");
/**
+ * Defines the shared type used by this module.
* @template T
* @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T>
*/
/**
+ * Defines the shared type used by this module.
* @template T
* @template R
* @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R>
@@ -27,6 +29,7 @@
/** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */
/** @typedef {import("./Compiler")} Compiler */
/**
+ * Defines the callback type used by this module.
* @template T
* @template [R=void]
* @typedef {import("./webpack").Callback<T, R>} Callback
@@ -40,6 +43,7 @@
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
/**
+ * Defines the run with dependencies handler callback.
* @callback RunWithDependenciesHandler
* @param {Compiler} compiler
* @param {Callback<MultiStats>} callback
@@ -47,6 +51,7 @@
*/
/**
+ * Defines the multi compiler options type used by this module.
* @typedef {object} MultiCompilerOptions
* @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
*/
@@ -57,6 +62,7 @@
module.exports = class MultiCompiler {
/**
+ * Creates an instance of MultiCompiler.
* @param {Compiler[] | Record<string, Compiler>} compilers child compilers
* @param {MultiCompilerOptions} options options
*/
@@ -129,6 +135,7 @@
_validateCompilersOptions() {
if (this.compilers.length < 2) return;
/**
+ * Adds the provided compiler to the multi compiler.
* @param {Compiler} compiler compiler
* @param {WebpackError} warning warning
*/
@@ -137,10 +144,11 @@
compilation.warnings.push(warning);
});
};
+ /** @type {Set<string>} */
const cacheNames = new Set();
for (const compiler of this.compilers) {
if (compiler.options.cache && "name" in compiler.options.cache) {
- const name = compiler.options.cache.name;
+ const name = /** @type {string} */ (compiler.options.cache.name);
if (cacheNames.has(name)) {
addWarning(
compiler,
@@ -186,6 +194,7 @@
}
/**
+ * Sets input file system.
* @param {InputFileSystem} value the new input file system
*/
set inputFileSystem(value) {
@@ -199,6 +208,7 @@
}
/**
+ * Sets output file system.
* @param {OutputFileSystem} value the new output file system
*/
set outputFileSystem(value) {
@@ -212,6 +222,7 @@
}
/**
+ * Sets watch file system.
* @param {WatchFileSystem} value the new watch file system
*/
set watchFileSystem(value) {
@@ -221,6 +232,7 @@
}
/**
+ * Sets intermediate file system.
* @param {IntermediateFileSystem} value the new intermediate file system
*/
set intermediateFileSystem(value) {
@@ -234,6 +246,7 @@
}
/**
+ * Gets infrastructure logger.
* @param {string | (() => string)} name name of the logger, or function called once to get the logger name
* @returns {Logger} a logger with that name
*/
@@ -242,6 +255,7 @@
}
/**
+ * Updates dependencies using the provided compiler.
* @param {Compiler} compiler the child compiler
* @param {string[]} dependencies its dependencies
* @returns {void}
@@ -251,15 +265,17 @@
}
/**
+ * Validate dependencies.
* @param {Callback<MultiStats>} callback signals when the validation is complete
* @returns {boolean} true if the dependencies are valid
*/
validateDependencies(callback) {
- /** @type {Set<{source: Compiler, target: Compiler}>} */
+ /** @type {Set<{ source: Compiler, target: Compiler }>} */
const edges = new Set();
/** @type {string[]} */
const missing = [];
/**
+ * Returns target was found.
* @param {Compiler} compiler compiler
* @returns {boolean} target was found
*/
@@ -272,8 +288,9 @@
return false;
};
/**
- * @param {{source: Compiler, target: Compiler}} e1 edge 1
- * @param {{source: Compiler, target: Compiler}} e2 edge 2
+ * Returns result.
+ * @param {{ source: Compiler, target: Compiler }} e1 edge 1
+ * @param {{ source: Compiler, target: Compiler }} e2 edge 2
* @returns {number} result
*/
const sortEdges = (e1, e2) =>
@@ -332,6 +349,7 @@
// TODO webpack 6 remove
/**
+ * Run with dependencies.
* @deprecated This method should have been private
* @param {Compiler[]} compilers the child compilers
* @param {RunWithDependenciesHandler} fn a handler to run for each compiler
@@ -339,17 +357,21 @@
* @returns {void}
*/
runWithDependencies(compilers, fn, callback) {
+ /** @type {Set<string>} */
const fulfilledNames = new Set();
let remainingCompilers = compilers;
/**
+ * Checks whether this multi compiler is dependency fulfilled.
* @param {string} d dependency
* @returns {boolean} when dependency was fulfilled
*/
const isDependencyFulfilled = (d) => fulfilledNames.has(d);
/**
+ * Gets ready compilers.
* @returns {Compiler[]} compilers
*/
const getReadyCompilers = () => {
+ /** @type {Compiler[]} */
const readyCompilers = [];
const list = remainingCompilers;
remainingCompilers = [];
@@ -366,6 +388,7 @@
return readyCompilers;
};
/**
+ * Processes the provided stat.
* @param {Callback<Stats[]>} callback callback
* @returns {void}
*/
@@ -376,12 +399,12 @@
(compiler, callback) => {
fn(compiler, (err) => {
if (err) return callback(err);
- fulfilledNames.add(compiler.name);
+ fulfilledNames.add(/** @type {string} */ (compiler.name));
runCompilers(callback);
});
},
(err, results) => {
- callback(err, results);
+ callback(/** @type {Error | null} */ (err), results);
}
);
};
@@ -389,6 +412,7 @@
}
/**
+ * Returns result of setup.
* @template SetupResult
* @param {(compiler: Compiler, index: number, doneCallback: Callback<Stats>, isBlocked: () => boolean, setChanged: () => void, setInvalid: () => void) => SetupResult} setup setup a single compiler
* @param {(compiler: Compiler, setupResult: SetupResult, callback: Callback<Stats>) => void} run run/continue a single compiler
@@ -445,6 +469,7 @@
let running = 0;
const parallelism = /** @type {number} */ (this._options.parallelism);
/**
+ * Processes the provided node.
* @param {Node} node node
* @param {(Error | null)=} err error
* @param {Stats=} stats result
@@ -480,6 +505,7 @@
processQueue();
};
/**
+ * Node invalid from parent.
* @param {Node} node node
* @returns {void}
*/
@@ -494,6 +520,7 @@
}
};
/**
+ * Processes the provided node.
* @param {Node} node node
* @returns {void}
*/
@@ -508,6 +535,7 @@
}
};
/**
+ * Processes the provided node.
* @param {Node} node node
* @returns {void}
*/
@@ -567,6 +595,7 @@
running === 0 &&
nodes.every((node) => node.state === "done")
) {
+ /** @type {Stats[]} */
const stats = [];
for (const node of nodes) {
const result = node.result;
@@ -585,6 +614,7 @@
}
/**
+ * Returns a compiler watcher.
* @param {WatchOptions | WatchOptions[]} watchOptions the watcher's options
* @param {Callback<MultiStats>} handler signals when the call finishes
* @returns {MultiWatching | undefined} a compiler watcher
@@ -623,6 +653,7 @@
}
/**
+ * Processes the provided multi stat.
* @param {Callback<MultiStats>} callback signals when the call finishes
* @returns {void}
*/
@@ -657,6 +688,7 @@
}
/**
+ * Processes the provided error callback.
* @param {ErrorCallback} callback signals when the compiler closes
* @returns {void}
*/
@@ -667,7 +699,7 @@
compiler.close(callback);
},
(error) => {
- callback(error);
+ callback(/** @type {Error | null} */ (error));
}
);
}
--
Gitblit v1.9.3