Skip to content

Commit

Permalink
Update frontend to Node 18 (#861)
Browse files Browse the repository at this point in the history
Using v18.18.1 because GitHub Actions uses v18.18.0 at the moment, and it is prone to a bug in webpack: nodejs/node#49911 (comment)
  • Loading branch information
anantakrishna authored Oct 12, 2023
1 parent 89996be commit 370a148
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,5 @@
"vulnerabilityAlerts": {
"schedule": ["at any time"],
"dependencyDashboardApproval": false
},
"packageRules": [
{
"matchFileNames": ["frontend/**"],
"matchCategories": ["node"],
"enabled": false
}
]
}
}
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:unit": "npm run test"
},
"engines": {
"node": "16"
"node": "18.18.1"
},
"dependencies": {
"@casl/ability": "4.1.6",
Expand Down
20 changes: 20 additions & 0 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down

0 comments on commit 370a148

Please sign in to comment.