From 00935251386e97741145598c7287c7ed1f7b559f Mon Sep 17 00:00:00 2001 From: Justin Robb Date: Wed, 20 Oct 2021 15:31:23 -0700 Subject: [PATCH] Use `md5` has for caching on node v17 (#918) --- src/cache.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cache.js b/src/cache.js index 7f7721ff..35e78819 100644 --- a/src/cache.js +++ b/src/cache.js @@ -63,7 +63,14 @@ const write = async function (filename, compress, result) { * @return {String} */ const filename = function (source, identifier, options) { - const hash = crypto.createHash("md4"); + // md4 hashing is not supported starting with node v17.0.0 + const majorNodeVersion = parseInt(process.versions.node.split(".")[0], 10); + let hashType = "md4"; + if (majorNodeVersion >= 17) { + hashType = "md5"; + } + + const hash = crypto.createHash(hashType); const contents = JSON.stringify({ source, options, identifier });