Skip to content

Commit e6937f0

Browse files
committed
chore: drop support for Nodejs 20
BREAKING CHANGE: This drops support for Nodejs 20, and drops the polyfill for Object.groupBy - instead calling it directly. This means this version will fail to run in Nodejs 20 contexts without an Object.groupBy polyfill. Going forward and issues relating to support for Nodejs 20 will be closed, our minimum supported Nodejs version is 22 - which we will aim to support until April 2027, when it becomes EOL.
1 parent 7622c1a commit e6937f0

5 files changed

Lines changed: 7 additions & 23 deletions

File tree

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
# - 'macos-latest'
1313
# - 'windows-latest'
1414
node_version:
15+
- '25'
1516
- '24'
1617
- '22'
17-
- '20'
1818
name: Node.js ${{ matrix.node_version }} on ${{ matrix.os }}
1919
runs-on: ${{ matrix.os }}
2020
steps:

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default [
1313
languageOptions: {
1414
globals: { ...globals.builtin, ...globals.node },
1515
},
16-
settings: { node: { version: '20' } },
16+
settings: { node: { version: '22' } },
1717
},
1818
{ ignores: ['index.cjs'] },
1919
]

index.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,6 @@ const sortObjectBy = (comparator, deep) => {
3434

3535
return over
3636
}
37-
const objectGroupBy =
38-
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax -- Safe
39-
Object.groupBy ||
40-
// Remove this when we drop support for Node.js 20
41-
((array, callback) => {
42-
const result = Object.create(null)
43-
for (const value of array) {
44-
const key = callback(value)
45-
if (result[key]) {
46-
result[key].push(value)
47-
} else {
48-
result[key] = [value]
49-
}
50-
}
51-
return result
52-
})
5337
const sortObject = sortObjectBy()
5438
const sortURLObject = sortObjectBy(['type', 'url'])
5539
const sortPeopleObject = sortObjectBy(['name', 'email', 'url'])
@@ -393,7 +377,7 @@ const sortScripts = onObject((scripts, packageJson) => {
393377
- Move `default` condition to bottom
394378
*/
395379
const sortConditions = (conditions) => {
396-
const { defaultConditions = [], restConditions = [] } = objectGroupBy(
380+
const { defaultConditions = [], restConditions = [] } = Object.groupBy(
397381
conditions,
398382
(condition) => {
399383
if (condition === 'default') {
@@ -408,7 +392,7 @@ const sortConditions = (conditions) => {
408392
}
409393

410394
const sortExports = onObject((exports) => {
411-
const { paths = [], conditions = [] } = objectGroupBy(
395+
const { paths = [], conditions = [] } = Object.groupBy(
412396
Object.keys(exports),
413397
(key) => (key.startsWith('.') ? 'paths' : 'conditions'),
414398
)
@@ -597,7 +581,7 @@ function sortPackageJson(jsonIsh, options = {}) {
597581

598582
if (Array.isArray(sortOrder)) {
599583
const keys = Object.keys(json)
600-
const { privateKeys = [], publicKeys = [] } = objectGroupBy(
584+
const { privateKeys = [], publicKeys = [] } = Object.groupBy(
601585
keys,
602586
(key) => (key[0] === '_' ? 'privateKeys' : 'publicKeys'),
603587
)

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@
103103
"tstyche": "^5.0.1"
104104
},
105105
"engines": {
106-
"node": ">=20"
106+
"node": ">=22"
107107
}
108108
}

0 commit comments

Comments
 (0)