-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MD4 shim for Webpack4 on Node18+ (#1046)
- Loading branch information
1 parent
beef9b4
commit 3f98954
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const crypto = require('crypto') | ||
// MD4 algorithm is not available anymore in NodeJS 17+ (because of lib SSL 3). | ||
// https://stackoverflow.com/a/72219174/1447466 | ||
// config.output.hashFunction = 'md5' | ||
// is supposed to disables MD4, but it doesn't work correctly until | ||
// https://github.com/webpack/webpack/pull/14306 | ||
try { | ||
crypto.createHash('md4') | ||
} catch (e) { | ||
let printed = false | ||
const print = alg => { | ||
if (alg != 'md4') return | ||
if (printed) return | ||
printed = true | ||
console.warn('MD4 is unsupported, replacing it with MD5') | ||
} | ||
const createHash = crypto.createHash | ||
crypto.createHash = (alg, ...params) => { | ||
print(alg) | ||
return createHash(alg == 'md4' ? 'md5' : alg, ...params) | ||
} | ||
} |