build: support node v22

This commit is contained in:
鲁树人 2025-05-09 05:46:18 +09:00
parent f22b05f40d
commit b0ee928199
4 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,21 @@
diff --git a/node_modules/babel-loader/lib/cache.js b/node_modules/babel-loader/lib/cache.js
index fced210..6b0c137 100644
--- a/node_modules/babel-loader/lib/cache.js
+++ b/node_modules/babel-loader/lib/cache.js
@@ -91,15 +91,7 @@ const write = /*#__PURE__*/function () {
const filename = function (source, identifier, options) {
- // 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 hash = crypto.createHash("sha256");
const contents = JSON.stringify({
source,
options,

View File

@ -0,0 +1,13 @@
diff --git a/node_modules/copy-webpack-plugin/dist/postProcessPattern.js b/node_modules/copy-webpack-plugin/dist/postProcessPattern.js
index 8354f00..9bdf6ed 100644
--- a/node_modules/copy-webpack-plugin/dist/postProcessPattern.js
+++ b/node_modules/copy-webpack-plugin/dist/postProcessPattern.js
@@ -69,7 +69,7 @@ function postProcessPattern(globalRef, pattern, file) {
name: _package.name,
version: _package.version,
pattern,
- hash: _crypto.default.createHash('md4').update(content).digest('hex')
+ hash: _crypto.default.createHash('sha256').update(content).digest('hex')
});
return _cacache.default.get(globalRef.cacheDir, cacheKey).then(result => {
logger.debug(`getting cached transformation for '${file.absoluteFrom}'`);

View File

@ -0,0 +1,13 @@
diff --git a/node_modules/terser-webpack-plugin/dist/index.js b/node_modules/terser-webpack-plugin/dist/index.js
index 6268f6b..1cb8f2c 100644
--- a/node_modules/terser-webpack-plugin/dist/index.js
+++ b/node_modules/terser-webpack-plugin/dist/index.js
@@ -214,7 +214,7 @@ class TerserPlugin {
// eslint-disable-next-line global-require
'terser-webpack-plugin': require('../package.json').version,
'terser-webpack-plugin-options': this.options,
- hash: _crypto.default.createHash('md4').update(input).digest('hex')
+ hash: _crypto.default.createHash('sha256').update(input).digest('hex')
};
task.cacheKeys = this.options.cacheKeys(defaultCacheKeys, file);
}

View File

@ -0,0 +1,26 @@
diff --git a/node_modules/webpack/lib/optimize/SplitChunksPlugin.js b/node_modules/webpack/lib/optimize/SplitChunksPlugin.js
index e7d560b..94a8401 100644
--- a/node_modules/webpack/lib/optimize/SplitChunksPlugin.js
+++ b/node_modules/webpack/lib/optimize/SplitChunksPlugin.js
@@ -22,7 +22,7 @@ const deterministicGroupingForModules = /** @type {function(DeterministicGroupin
const hashFilename = name => {
return crypto
- .createHash("md4")
+ .createHash("sha256")
.update(name)
.digest("hex")
.slice(0, 8);
diff --git a/node_modules/webpack/lib/util/createHash.js b/node_modules/webpack/lib/util/createHash.js
index 64de510..4cc3fc9 100644
--- a/node_modules/webpack/lib/util/createHash.js
+++ b/node_modules/webpack/lib/util/createHash.js
@@ -131,6 +131,8 @@ module.exports = algorithm => {
// TODO add non-cryptographic algorithm here
case "debug":
return new DebugHash();
+ case 'md4':
+ algorithm = "sha256";
default:
return new BulkUpdateDecorator(require("crypto").createHash(algorithm));
}