fix: logic

This commit is contained in:
alexander-akait 2025-10-07 15:44:25 +03:00
parent 4c17f5160c
commit 63411bd7f0
5 changed files with 42 additions and 16 deletions

View File

@ -539,12 +539,7 @@ export type GlobalObject = string;
/**
* Digest type used for the hash.
*/
export type HashDigest = Encoding;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "Encoding".
*/
export type Encoding =
export type HashDigest =
| "base64"
| "base64url"
| "hex"
@ -808,6 +803,22 @@ export type CssParserUrl = boolean;
* Options for defer import.
*/
export type DeferImportExperimentOptions = boolean;
/**
* Supported encoding.
*/
export type Encoding =
| "base64"
| "base64url"
| "hex"
| "binary"
| "utf8"
| "utf-8"
| "utf16le"
| "utf-16le"
| "latin1"
| "ascii"
| "ucs2"
| "ucs-2";
/**
* A Function returning a Promise resolving to a normalized entry.
*/

View File

@ -127,7 +127,12 @@ class BulkUpdateDecorator extends Hash {
}
return result;
}
const result = this.hash.digest(encoding);
const digestResult = this.hash.digest(encoding);
// Compatibility with the old hash library
const result =
typeof digestResult === "string"
? digestResult
: /** @type {NodeJS.TypedArray} */ (digestResult).toString();
if (digestCache !== undefined) {
digestCache.set(buffer, result);
}

File diff suppressed because one or more lines are too long

View File

@ -661,6 +661,7 @@
}
},
"Encoding": {
"description": "Supported encoding.",
"enum": [
"base64",
"base64url",
@ -1584,12 +1585,8 @@
"minLength": 1
},
"HashDigest": {
"description": "Digest type used for the hash.",
"anyOf": [
{
"$ref": "#/definitions/Encoding"
}
]
"$ref": "#/definitions/Encoding",
"description": "Digest type used for the hash."
},
"HashDigestLength": {
"description": "Number of chars which are used for the hash.",

17
types.d.ts vendored
View File

@ -6272,6 +6272,19 @@ declare class Hash {
*/
digest(encoding: Encoding): string;
}
type HashDigest =
| "base64"
| "base64url"
| "hex"
| "binary"
| "utf8"
| "utf-8"
| "utf16le"
| "utf-16le"
| "latin1"
| "ascii"
| "ucs2"
| "ucs-2";
type HashFunction = string | typeof Hash;
declare interface HashLike {
/**
@ -11729,7 +11742,7 @@ declare interface NormalModuleLoaderContext<OptionsType> {
mode: "none" | "development" | "production";
webpack?: boolean;
hashFunction: HashFunction;
hashDigest: Encoding;
hashDigest: HashDigest;
hashDigestLength: number;
hashSalt?: string;
_module?: NormalModule;
@ -14431,7 +14444,7 @@ declare interface RealContentHashPluginOptions {
/**
* the hash digest to use
*/
hashDigest: Encoding;
hashDigest: HashDigest;
}
declare interface RealDependencyLocation {
start: SourcePosition;