Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failed with debug hash #16950

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/util/createHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ class DebugHash extends Hash {
*/
update(data, inputEncoding) {
if (typeof data !== "string") data = data.toString("utf-8");
if (data.startsWith("debug-digest-")) {
data = Buffer.from(data.slice("debug-digest-".length), "hex").toString();
const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
if (data.startsWith(prefix)) {
data = Buffer.from(data.slice(prefix.length), "hex").toString();
}
this.string += `[${data}](${new Error().stack.split("\n", 3)[2]})\n`;
return this;
Expand All @@ -120,7 +121,7 @@ class DebugHash extends Hash {
* @returns {string|Buffer} digest
*/
digest(encoding) {
return "debug-digest-" + Buffer.from(this.string).toString("hex");
return Buffer.from("@webpack-debug-digest@" + this.string).toString("hex");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = module.id;
8 changes: 8 additions & 0 deletions test/configCases/custom-hash-function/debug-hash/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
it("debug hash should works", function () {
var ids = [];
for(var i = 1; i <= 15; i++) {
var id = require("./files/file" + i + ".js");
expect(ids.indexOf(id)).toBe(-1);
ids.push(id);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
output: {
hashFunction: "debug"
}
}
];