feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -91,6 +91,7 @@ module.exports = class MultiCompiler {
const compiler = this.compilers[index];
const compilerIndex = index;
let compilerDone = false;
// eslint-disable-next-line no-loop-func
compiler.hooks.done.tap("MultiCompiler", stats => {
if (!compilerDone) {
compilerDone = true;
@@ -103,6 +104,7 @@ module.exports = class MultiCompiler {
);
}
});
// eslint-disable-next-line no-loop-func
compiler.hooks.invalid.tap("MultiCompiler", () => {
if (compilerDone) {
compilerDone = false;
@@ -172,18 +174,6 @@ module.exports = class MultiCompiler {
throw new Error("Cannot read inputFileSystem of a MultiCompiler");
}
get outputFileSystem() {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
get watchFileSystem() {
throw new Error("Cannot read watchFileSystem of a MultiCompiler");
}
get intermediateFileSystem() {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
/**
* @param {InputFileSystem} value the new input file system
*/
@@ -193,6 +183,10 @@ module.exports = class MultiCompiler {
}
}
get outputFileSystem() {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
/**
* @param {OutputFileSystem} value the new output file system
*/
@@ -202,6 +196,10 @@ module.exports = class MultiCompiler {
}
}
get watchFileSystem() {
throw new Error("Cannot read watchFileSystem of a MultiCompiler");
}
/**
* @param {WatchFileSystem} value the new watch file system
*/
@@ -220,6 +218,10 @@ module.exports = class MultiCompiler {
}
}
get intermediateFileSystem() {
throw new Error("Cannot read outputFileSystem of a MultiCompiler");
}
/**
* @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
* @returns {Logger} a logger with that name
@@ -263,16 +265,11 @@ module.exports = class MultiCompiler {
* @param {{source: Compiler, target: Compiler}} e2 edge 2
* @returns {number} result
*/
const sortEdges = (e1, e2) => {
return (
/** @type {string} */
(e1.source.name).localeCompare(
/** @type {string} */ (e2.source.name)
) ||
/** @type {string} */
(e1.target.name).localeCompare(/** @type {string} */ (e2.target.name))
);
};
const sortEdges = (e1, e2) =>
/** @type {string} */
(e1.source.name).localeCompare(/** @type {string} */ (e2.source.name)) ||
/** @type {string} */
(e1.target.name).localeCompare(/** @type {string} */ (e2.target.name));
for (const source of this.compilers) {
const dependencies = this.dependencies.get(source);
if (dependencies) {
@@ -340,8 +337,8 @@ module.exports = class MultiCompiler {
* @returns {Compiler[]} compilers
*/
const getReadyCompilers = () => {
let readyCompilers = [];
let list = remainingCompilers;
const readyCompilers = [];
const list = remainingCompilers;
remainingCompilers = [];
for (const c of list) {
const dependencies = this.dependencies.get(c);
@@ -514,7 +511,7 @@ module.exports = class MultiCompiler {
/** @type {SetupResult[]} */
const setupResults = [];
nodes.forEach((node, i) => {
for (const [i, node] of nodes.entries()) {
setupResults.push(
(node.setupResult = setup(
node.compiler,
@@ -525,7 +522,7 @@ module.exports = class MultiCompiler {
() => nodeInvalid(node)
))
);
});
}
let processing = true;
const processQueue = () => {
if (processing) return;
@@ -533,6 +530,7 @@ module.exports = class MultiCompiler {
process.nextTick(processQueueWorker);
};
const processQueueWorker = () => {
// eslint-disable-next-line no-unmodified-loop-condition
while (running < parallelism && queue.length > 0 && !errored) {
const node = /** @type {Node} */ (queue.dequeue());
if (