fix(config): upgrade md4 -> md5 on node > 16 (#19108)

This commit is contained in:
Daniel Roe 2023-02-20 20:28:43 +00:00 committed by GitHub
parent c0f7e3344e
commit 2c6b593a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -519,6 +519,17 @@ export function getNuxtConfig (_options) {
options.build.indicator = false
}
// Monkey patch crypto.createHash in dev/build to upgrade hashing fnction
if (parseInt(process.versions.node.slice(0, 2)) > 16) {
options.buildModules.push(function patchMD4 () {
const crypto = require('crypto')
const _createHash = crypto.createHash
crypto.createHash = function (algorithm, options) {
return _createHash(algorithm === 'md4' ? 'md5' : algorithm, options)
}
})
}
// Components Module
if (!options._start && getPKG('@nuxt/components')) {
options._modules.push('@nuxt/components')