From 370a148b04bb70c338935c2dcd7271b434c739d5 Mon Sep 17 00:00:00 2001 From: Ananta Krsna dasa Date: Thu, 12 Oct 2023 20:30:24 +0530 Subject: [PATCH] Update frontend to Node 18 (#861) Using v18.18.1 because GitHub Actions uses v18.18.0 at the moment, and it is prone to a bug in webpack: https://github.com/nodejs/node/issues/49911#issuecomment-1756119733 --- .github/workflows/deployment.yml | 5 +++-- .renovaterc.json | 9 +-------- frontend/package-lock.json | 2 +- frontend/package.json | 2 +- frontend/vue.config.js | 20 ++++++++++++++++++++ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 773592667..53039ad40 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -32,8 +32,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: - # Using node version from functions because it's more likely to be the freshest - node-version-file: functions/package.json + # Using node version from frontend because it's more sensitive in this regard + # See https://github.com/nodejs/node/issues/49911#issuecomment-1756119733 + node-version-file: frontend/package.json cache: npm cache-dependency-path: | functions/package-lock.json diff --git a/.renovaterc.json b/.renovaterc.json index a696ecd9f..f8ab34518 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -16,12 +16,5 @@ "vulnerabilityAlerts": { "schedule": ["at any time"], "dependencyDashboardApproval": false - }, - "packageRules": [ - { - "matchFileNames": ["frontend/**"], - "matchCategories": ["node"], - "enabled": false - } - ] + } } diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6137d0bab..dd2e2b2a4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -83,7 +83,7 @@ "vue-template-compiler": "2.6.14" }, "engines": { - "node": "16" + "node": "18.18.1" } }, "node_modules/@achrinza/node-ipc": { diff --git a/frontend/package.json b/frontend/package.json index 2af8978c0..f078783f6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,7 @@ "test:unit": "npm run test" }, "engines": { - "node": "16" + "node": "18.18.1" }, "dependencies": { "@casl/ability": "4.1.6", diff --git a/frontend/vue.config.js b/frontend/vue.config.js index c5d3f2b36..e48ae46c5 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -1,3 +1,23 @@ +const crypto = require('crypto'); + +/** + * The MD4 algorithm is not available anymore in Node.js 17+ (because of library SSL 3). + * In that case, silently replace MD4 by the MD5 algorithm. + * From https://stackoverflow.com/a/72219174/3082178. + * Just setting webpack's `output.hashFunction` is not enough, + * something else is using MD4 (see https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported/73465262#comment131441027_73465262). + */ +try { + crypto.createHash('md4'); +} catch (e) { + console.warn( + 'Crypto "MD4" is not supported anymore by this Node.js version. Using MD5 instead.' + ); + const origCreateHash = crypto.createHash; + crypto.createHash = (alg, opts) => + origCreateHash(alg === 'md4' ? 'md5' : alg, opts); +} + module.exports = { chainWebpack: (config) => { config.plugins.delete('prefetch');