Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Node.js LTS ‘Iron’ (v20) release version #4201

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Sep 11, 2023

This PR allows Node.js LTS ‘Iron’ (v20) to install, run and build GOV.UK Frontend

GOV.UK Frontend requires Node.js version 12.17.0 or later to support ECMAScript modules. Where possible, we recommend you install the latest Long Term Support (LTS) version

Changes included:

  1. Updating .browserslistrc for Node.js 20
    So Babel is aware we need to support only node 20

  2. Updating .nvmrc for Node.js 20
    So tools like nvm and asdf allow the lts/iron LTS release

  3. Bump the package.json engines.node range
    Ensures npm install and other scripts check the local Node.js version is allowed

  4. Bump the package.json engines.npm range
    Ensure support for npm@10 rather than npm@9

@colinrotherham colinrotherham added the github_actions Pull requests that update GitHub Actions code label Sep 11, 2023
@colinrotherham colinrotherham requested a review from a team as a code owner September 11, 2023 12:58
@colinrotherham colinrotherham changed the title Switch GitHub Actions workflows to Node.js 20.6.1 [SPIKE] Switch GitHub Actions workflows to Node.js 20.6.1 Sep 11, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 11, 2023 12:58 Inactive
@colinrotherham colinrotherham changed the base branch from main to setup-node September 11, 2023 12:59
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 12, 2023 11:47 Inactive
@colinrotherham colinrotherham changed the base branch from setup-node to test-filenames-fetch-path September 12, 2023 16:24
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 12, 2023 16:24 Inactive
@github-actions
Copy link

github-actions bot commented Sep 12, 2023

📋 Stats

File sizes

File Size
dist/govuk-frontend-5.0.0-beta.0.min.css 114 KiB
dist/govuk-frontend-5.0.0-beta.0.min.js 37.85 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 77.08 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 72.37 KiB
packages/govuk-frontend/dist/govuk/all.mjs 3.8 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 113.99 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 37.92 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.3 KiB

Modules

File Size
all.mjs 68.7 KiB
components/accordion/accordion.mjs 21.35 KiB
components/button/button.mjs 4.48 KiB
components/character-count/character-count.mjs 20.79 KiB
components/checkboxes/checkboxes.mjs 5.61 KiB
components/error-summary/error-summary.mjs 5.79 KiB
components/exit-this-page/exit-this-page.mjs 15.79 KiB
components/header/header.mjs 3.68 KiB
components/notification-banner/notification-banner.mjs 4.32 KiB
components/radios/radios.mjs 4.6 KiB
components/skip-link/skip-link.mjs 3.6 KiB
components/tabs/tabs.mjs 9.37 KiB

View stats and visualisations on the review app


Action run for 19173ea

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 13, 2023 11:04 Inactive
Base automatically changed from test-filenames-fetch-path to main September 18, 2023 08:59
@colinrotherham colinrotherham changed the title [SPIKE] Switch GitHub Actions workflows to Node.js 20.6.1 [SPIKE] Switch GitHub Actions workflows to Node.js 20 Sep 22, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 22, 2023 13:16 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 September 29, 2023 13:15 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 11, 2023 15:00 Inactive
@colinrotherham
Copy link
Contributor Author

Blocked until Node.js 20 LTS released: 24 October 2023

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 17, 2023 09:57 Inactive
@colinrotherham colinrotherham changed the title [SPIKE] Switch GitHub Actions workflows to Node.js 20 [SPIKE] Allow Node.js LTS ‘Iron’ (v20) release version Oct 23, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 23, 2023 20:20 Inactive
@colinrotherham colinrotherham changed the title [SPIKE] Allow Node.js LTS ‘Iron’ (v20) release version Allow Node.js LTS ‘Iron’ (v20) release version Oct 26, 2023
@colinrotherham
Copy link
Contributor Author

Heroku builds are still failing, must still be rolling out:

-----> Installing binaries
       engines.node (package.json):  ^20.9.0
       engines.npm (package.json):   ^10.1.0
       
       Resolving node version ^20.9.0...
       Could not find Node version corresponding to version requirement: ^20.9.0
-----> Build failed
 !     No matching version found for Node: ^20.9.0

We'll keep an eye on the Heroku Changelog

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 26, 2023 20:58 Inactive
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Oct 26, 2023

All sorted, Heroku is ready to go:

Node.js 20.9.0 and 21.1.0 now available
Node.js versions 20.9.0 and 21.1.0 have been made available for builds on Heroku. For additional information, please see our article on Node.js Support.

@colinrotherham
Copy link
Contributor Author

From our "waiting for" list in #4201 (comment) it looks like we're just missing asdf support:

Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. nvm was happy with lts/iron locally (and Github actions and Heroku) on CI, hopefully asdf won't be long.

Do you know if people will need to update asdf locally for it to undersand lts/iron?

@colinrotherham
Copy link
Contributor Author

@romaricpascal Nah it does an automatic update on asdf install

Wonder if we should use 20.x or something similarly compatible instead of code names?

@romaricpascal
Copy link
Member

20.x sounds a great way to not make us depend on the tools understanding the latest code name, so very up for that 😊

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 27, 2023 16:09 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 27, 2023 16:11 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4201 October 27, 2023 16:50 Inactive
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our discussion on Slack, it seems using 20 in .nvmrc causes trouble with asdf when Husky runs. That'd make lts/iron would be fine once asdf supports it, unless we figure why Husky and asdf don't play nicely.

It'll also be worth coordinating the merge with the rest of the team, so that people know to run nvm or asdf to set up the new version.

@colinrotherham
Copy link
Contributor Author

colinrotherham commented Oct 30, 2023

Thanks @romaricpascal

Let's stick with lts/hydrogen lts/iron now that asdf-vm/asdf-nodejs#377 has merged

Node.js version managers

I've added some notes for typical macOS + ZSH + Homebrew installs

For Node.js commit hook support via GUI (e.g. Tower) duplicate these changes into ~/.huskyrc

Using nvm

Check for updates using README Install & Update Script and check these lines are in ~/.zshrc

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Running nvm install will automatically download Node.js LTS v20.9.0

Using asdf

Check the Node.js asdf plugin is up to date via asdf plugin-update nodejs and these lines are in ~/.zshrc

# Resolves 'lts/iron' → 20 → 20.9.0
export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY=latest_available

. $(brew --prefix asdf)/libexec/asdf.sh

After setting ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY in ~/.zshrc we can opt in to "legacy version file" .nvmrc config support (see README Partial and codename versions) using the following ~/.asdfrc config line:

legacy_version_file = yes

Once both are set, asdf is able to expand codenames lts/iron and partial versions 18, 20, 20.9 etc into full 20.9.0 version numbers to avoid error messages such as:

No preset version installed for command npx
Please install a version by running one of the following:

asdf install nodejs 20

or add one of the following versions in your config file at /Users/username/.tool-versions
nodejs 18.18.2
nodejs 20.9.0
nodejs lts-iron

Running asdf install will automatically download Node.js LTS v20.9.0

@colinrotherham colinrotherham merged commit e398686 into main Oct 30, 2023
44 checks passed
@colinrotherham colinrotherham deleted the node-v20 branch October 30, 2023 10:55
colinrotherham added a commit that referenced this pull request Oct 30, 2023
The Node.js LTS v20 update in #4201 has stopped Dependabot from running

Rather than allow Node.js v18 and npm v9.6.5 we can remove `engine-strict=true`

```
Dependabot uses Node.js v18.18.2
 and NPM 9.6.5
. Due to the engine-strict setting, the update will not succeed.
```
querkmachine pushed a commit that referenced this pull request Nov 13, 2023
The Node.js LTS v20 update in #4201 has stopped Dependabot from running

Rather than allow Node.js v18 and npm v9.6.5 we can remove `engine-strict=true`

```
Dependabot uses Node.js v18.18.2
 and NPM 9.6.5
. Due to the engine-strict setting, the update will not succeed.
```
@colinrotherham colinrotherham removed their assignment Dec 8, 2023
owenatgov pushed a commit that referenced this pull request Jan 11, 2024
Allow Node.js LTS ‘Iron’ (v20) release version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code tooling
Projects
Development

Successfully merging this pull request may close these issues.

3 participants