Skip to content

Commit 33c3de3

Browse files
authored
Remove Node 20 support, harden engine requirements (#280)
* Add .node-version, fix minimumReleaseAge config for pnpm * Switch back to Node 22, add tests for 24, harden engine reqs * fix node 20 refs * fix comment
1 parent 796dc97 commit 33c3de3

11 files changed

Lines changed: 40 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ jobs:
106106
- name: Enable Corepack
107107
run: corepack enable
108108

109-
# Setup Node.js
109+
# Setup Node.js (version pinned in .node-version)
110110
- name: Setup Node
111111
uses: actions/setup-node@v6
112112
with:
113-
node-version: 22
113+
node-version-file: .node-version
114114
cache: pnpm
115115

116116
# Install Node.js dependencies

.github/workflows/formatting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Setup Node.js
3232
uses: actions/setup-node@v6
3333
with:
34-
node-version: 22
34+
node-version-file: .node-version
3535
cache: pnpm
3636

3737
- name: Install Node.js dependencies

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Setup Node.js
6464
uses: actions/setup-node@v6
6565
with:
66-
node-version: 22
66+
node-version-file: .node-version
6767
cache: pnpm
6868

6969
- name: Install Node.js dependencies

.github/workflows/release.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ on:
66
- "v*.*.*" # Trigger on version tags like v1.2.3
77

88
jobs:
9+
setup:
10+
name: Resolve primary Node version
11+
runs-on: ubuntu-latest
12+
permissions: {}
13+
outputs:
14+
primary-node: ${{ steps.read.outputs.version }}
15+
steps:
16+
- uses: actions/checkout@v6
17+
- id: read
18+
run: echo "version=$(cat .node-version)" >> "$GITHUB_OUTPUT"
19+
920
build-napi:
1021
name: Build N-API modules
1122
runs-on: ${{ matrix.settings.host }}
@@ -48,7 +59,7 @@ jobs:
4859
- name: Setup Node
4960
uses: actions/setup-node@v6
5061
with:
51-
node-version: 22
62+
node-version-file: .node-version
5263
cache: pnpm
5364
- name: Setup Rust
5465
uses: actions-rust-lang/setup-rust-toolchain@v1
@@ -96,16 +107,17 @@ jobs:
96107
if-no-files-found: error
97108

98109
test-targets:
99-
name: Cross-runtime test on ${{ matrix.settings.target }}
110+
name: Cross-runtime test on ${{ matrix.settings.target }} (Node ${{ matrix.node }})
100111
runs-on: ${{ matrix.settings.host }}
101-
needs: build-napi
112+
needs: [build-napi, setup]
102113
permissions: {}
103114
defaults:
104115
run:
105116
shell: bash
106117
strategy:
107118
fail-fast: false
108119
matrix:
120+
node: [22, 24]
109121
settings:
110122
- host: macos-15-intel
111123
target: x86_64-apple-darwin
@@ -147,7 +159,7 @@ jobs:
147159
- name: Setup Node
148160
uses: actions/setup-node@v6
149161
with:
150-
node-version: 22
162+
node-version: ${{ matrix.node }}
151163
cache: pnpm
152164
- name: Setup Rust
153165
uses: actions-rust-lang/setup-rust-toolchain@v1
@@ -175,7 +187,14 @@ jobs:
175187
run: pnpm install --frozen-lockfile
176188
- name: Run comprehensive tests (includes compilation)
177189
run: |
178-
if [ -n "${{ matrix.settings.test_runtimes }}" ]; then
190+
# Only the primary Node version (sourced from .node-version via the
191+
# setup job) runs the full cross-runtime suite. Other Node versions
192+
# only re-run the Node runtime tests, since Rust/Deno/Bun results
193+
# don't depend on the installed Node.
194+
if [ "${{ matrix.node }}" != "${{ needs.setup.outputs.primary-node }}" ]; then
195+
echo "Running Node-only tests for Node ${{ matrix.node }}"
196+
task test -- node
197+
elif [ -n "${{ matrix.settings.test_runtimes }}" ]; then
179198
echo "Running selective runtime tests: ${{ matrix.settings.test_runtimes }}"
180199
task test -- ${{ matrix.settings.test_runtimes }}
181200
else
@@ -205,7 +224,7 @@ jobs:
205224
- name: Setup Node
206225
uses: actions/setup-node@v6
207226
with:
208-
node-version: 24
227+
node-version-file: .node-version
209228
registry-url: https://registry.npmjs.org/
210229
cache: pnpm
211230
- name: Install Node.js dependencies

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
@jsr:registry=https://npm.jsr.io
2-
minimum-release-age=2880

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ target/ # Rust build artifacts
8080

8181
3. **Node.js 22.13+** - Build scripts and N-API builds. Run `corepack enable`
8282
once to activate pnpm 11 (the version is pinned via the `packageManager`
83-
field in `package.json`). pnpm 11 itself requires Node 22.13+ (consumers of
84-
the published package only need Node 20+, per the `engines` field).
83+
field in `package.json`). pnpm 11 itself requires Node 22.13+, which also
84+
matches the minimum supported runtime version declared in the `engines`
85+
field for consumers of the published package.
8586

8687
**Optional (for testing specific runtimes):**
8788

docs/CrossRuntimeSupport.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ The library automatically detects the current runtime and loads appropriate modu
2222
import { runtimeInfo } from "@printers/printers";
2323

2424
console.log(runtimeInfo);
25-
// Node.js: { name: "node", isDeno: false, isNode: true, isBun: false, version: "20.x.x" }
26-
// Deno: { name: "deno", isDeno: true, isNode: false, isBun: false, version: "1.x.x" }
25+
// Node.js: { name: "node", isDeno: false, isNode: true, isBun: false, version: "22.x.x" }
26+
// Deno: { name: "deno", isDeno: true, isNode: false, isBun: false, version: "2.x.x" }
2727
// Bun: { name: "bun", isDeno: false, isNode: false, isBun: true, version: "1.x.x" }
2828
```
2929

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
]
2121
},
2222
"engines": {
23-
"node": ">= 20"
23+
"node": ">= 22",
24+
"deno": ">= 2.0",
25+
"bun": ">= 1.0"
2426
},
2527
"repository": {
2628
"type": "git",

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
allowBuilds:
22
esbuild: true
3+
minimumReleaseAge: 2880

0 commit comments

Comments
 (0)