Most of our repositories are currently using Node v8 or v12. As node v8’s support ended on 31st December 2019 and node v12’s support is scheduled to end on 30th April 2022, we’re going to start upgrading our repositories to node v16.
The upgrade will take place in two phases as follows:
Phase 1: Add Node 16 support:
The Arbi-BOM team will generate PRs to upgrade to phase 1 automatically. If you don’t see a PR in your repo that indicates ‘upgrade to node 16’, please reach out to #external-frontend-working-group slack channel. There are some differnces acros repos based on their Workflow files so they won’t all look exactly alike.
Arbi-BOM will do this: Apply node ci modernizer to add node 16 support in GitHub workflows. This workflow will do the following:
Add the matrix with Node versions 12, 14 and 16.
Sets NPM version 8.x.x
Upgrade node and npm version in Dockerfile as well (if exists).
If the package uses node-sass currently, replace it with sass as node-sass is deprecated. Preferably, create a separate PR for this if it brings up a lot of changes.
Run tests with Node 12, 14, and 16, and if any of the tests fail, fix them.
Preferably upgrade edx-owned dependencies to the Node 16 supported version. For some commonly used libraries, Node 16 supported versions are as follows:
Update peer dependencies if possible.
Run npm update to update the dependencies, fix the conflicts and if any tests start to fail either fix them or ask owning the team for help. (optional)
IMPORTANT: While creating the PRs automatically using the cleanup job, the commit type was set to build but it should be feat so anyone working on the PR should update the type in PR title and commit message. (Sorry for this inconvenience).
Phase 2: Drop older node versions and fully migrate to Node 16
Drop Node 12 support:
Remove node 12 and 14 from node versions list in strategy matrix for ci workflow.
The MFEs will still be deployed using node12 in the gocd pipeline at this point, so please do this step once you have updated your Github workflows file, not too long after you merge the prior PR.
IMPORTANT: Ensure that MFE already has support for Node 16 and the package-lock.json has "lockfileVersion": 2. If it has "lockfileVersion": 1 then run npm install with Node 16 and npm 8 activated via nvm and push or go through the open PRs and you might find one automated PR already created by the bot for this purpose.
Jest v25 uses jsdom v15 (link) and all the tests related to focus started to fail due to the changes introduced in jsdom v15 (link). You may need to apply a fix to use attachTo in order to fix this issue following these references link1, link2. Reference PR
if you upgrade to a newer edx/eslint-config version (which is now using node16), you may also need to fix eslint issues such as this reference PR
Helpful local testing notes for testing out enterprise repos against node 16
To test enterprise MFEs against frontend-enterprise changes locally
Install nvm locally (you can use other node manages too this is just what I use)