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

@@ -13,6 +13,7 @@ const { runtimeToString, RuntimeSpecMap } = require("./util/runtime");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
/** @typedef {typeof import("./util/Hash")} Hash */
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
@@ -53,9 +54,9 @@ class CodeGenerationResults {
Caller might not support runtime-dependent code generation (opt-out via optimization.usedExports: "global").`
);
}
return first(results);
return /** @type {CodeGenerationResult} */ (first(results));
}
return entry.values().next().value;
return /** @type {CodeGenerationResult} */ (entry.values().next().value);
}
const result = entry.get(runtime);
if (result === undefined) {
@@ -86,9 +87,8 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
} else if (entry.size > 1) {
const results = new Set(entry.values());
return results.size === 1;
} else {
return entry.size === 1;
}
return entry.size === 1;
}
/**
@@ -98,13 +98,15 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
* @returns {Source} a source
*/
getSource(module, runtime, sourceType) {
return this.get(module, runtime).sources.get(sourceType);
return /** @type {Source} */ (
this.get(module, runtime).sources.get(sourceType)
);
}
/**
* @param {Module} module the module
* @param {RuntimeSpec} runtime runtime(s)
* @returns {ReadonlySet<string>} runtime requirements
* @returns {ReadOnlyRuntimeRequirements | null} runtime requirements
*/
getRuntimeRequirements(module, runtime) {
return this.get(module, runtime).runtimeRequirements;