Skip to content

Commit 9f9db3b

Browse files
Tighten engines and devEngines
`engines` requires `node` version `>=22.11.0` instead of `>=22`, while `22.11.0` is first long term support minor version of this major version. `devEngines` requires `node` version `^22.11.0 || ^24.11.0` instead of `22.x || 24.x`, while `22.11.0` and `24.11.0` are first long term support minor versions of those major versions. `devEngines` now requires `npm` version `^11.6.1` as it is first `npm` version delivered by `node` in version `24.11.0`. We require single major version of `npm` to generate `package-lock.json` of compatible structure. This would not be possible without requiring specific version of `npm`. `.github/workflows/build.yml` requires to split `build` job between `build_on_node_active_lts` to `build_on_node_previous_lts` due to fact that `build_on_node_previous_lts` requires to install newer `npm` and its `Set up Node.js` may fail due to this. This is due to `actions/setup-node@v6` that cannot install specific `npm` version, but fails with incompatible version defined in `devEngines`. `.github/workflows/build.yml` sets only major version of runtime engines to use the latest.
1 parent d4f358e commit 9f9db3b

3 files changed

Lines changed: 87 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,83 @@ name: Build
22

33
on: [ pull_request ]
44

5+
# We build distribution CSS and JS on both the active LTS and previous LTS Node.js versions,
6+
# to ensure compatibility across a wider range of environments. Those versions are defined
7+
# in package.json `devEngines` field and must match the versions defined in `env` section below.
8+
#
9+
# As package.json does not support comments, we document the version mapping here.
10+
#
11+
# `engines` field in package.json defines the minimum required Node.js version for running the package.
12+
# We set it to the first released previous LTS version of Node.js. This means we allow users
13+
# to run the package on this version and any later versions.
14+
#
15+
# "engines": {
16+
# "node": ">=22.11.0"
17+
# }
18+
#
19+
# `devEngines` field in package.json defines the Node.js versions used for development and building.
20+
# We set both to the first released active and previous LTS versions of Node.js. We also set
21+
# the npm version to the version of npm bundled with the first released active LTS Node.js version.
22+
# This means we strictly require one of those versions for development and building.
23+
#
24+
# "devEngines": {
25+
# "runtime": {
26+
# "name": "node",
27+
# "version": "^22.11.0 || ^24.11.0",
28+
# "onFail": "error"
29+
# },
30+
# "packageManager": {
31+
# "name": "npm",
32+
# "version": "^11.6.1",
33+
# "onFail": "error"
34+
# }
35+
# }
36+
#
37+
# Versions defined in `env` use major version numbers only to install the latest minor/patch.
38+
39+
env:
40+
NODE_ACTIVE_LTS_VERSION: 24
41+
NODE_PREVIOUS_LTS_VERSION: 22
42+
NPM_VERSION: 11
43+
544
jobs:
6-
build:
7-
name: Build distribution CSS and JS
45+
build_on_node_previous_lts:
46+
name: Build distribution CSS and JS (Node Previous LTS)
47+
runs-on: ubuntu-24.04
48+
steps:
49+
- name: Clone repository
50+
uses: actions/checkout@v6
51+
52+
- name: Set up Node.js (${{ env.NODE_PREVIOUS_LTS_VERSION }})
53+
uses: actions/setup-node@v6
54+
with:
55+
node-version: ${{ env.NODE_PREVIOUS_LTS_VERSION }}
56+
cache: npm
57+
continue-on-error: true
58+
59+
- name: Install npm@${{ env.NPM_VERSION }}
60+
run: npm install -g npm@${{ env.NPM_VERSION }}
61+
62+
- name: Print Node.js and npm version
63+
run: node --version && npm --version
64+
65+
- name: Install
66+
run: npm ci
67+
68+
- name: Build
69+
run: npm run build
70+
71+
build_on_node_active_lts:
72+
name: Build distribution CSS and JS (Node Active LTS)
873
runs-on: ubuntu-24.04
9-
strategy:
10-
matrix:
11-
node: [ 22, 24 ]
1274
steps:
1375
- name: Clone repository
14-
uses: actions/checkout@v4
76+
uses: actions/checkout@v6
1577

16-
- name: Set up Node.js ${{ matrix.node }}
17-
uses: actions/setup-node@v4
78+
- name: Set up Node.js (${{ env.NODE_ACTIVE_LTS_VERSION }})
79+
uses: actions/setup-node@v6
1880
with:
19-
node-version: ${{ matrix.node }}
81+
node-version: ${{ env.NODE_ACTIVE_LTS_VERSION }}
2082
cache: npm
2183

2284
- name: Print Node.js and npm version

package-lock.json

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@
2929
"url": "https://github.com/react-ui-org/react-ui"
3030
},
3131
"engines": {
32-
"node": ">=22"
32+
"node": ">=22.11.0"
3333
},
3434
"devEngines": {
3535
"runtime": {
3636
"name": "node",
37-
"version": "22.x || 24.x",
37+
"version": "^22.11.0 || ^24.11.0",
3838
"onFail": "error"
3939
},
4040
"packageManager": {
4141
"name": "npm",
42+
"version": "^11.6.1",
4243
"onFail": "error"
4344
}
4445
},

0 commit comments

Comments
 (0)