Skip to content

Commit d51292c

Browse files
committed
refactor!: drop support for Nodejs 20 (#412)
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 c22cfe8 commit d51292c

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'])
@@ -430,7 +414,7 @@ const sortScripts = onObject((scripts, packageJson) => {
430414
- Move `default` condition to bottom
431415
*/
432416
const sortConditions = (conditions) => {
433-
const { defaultConditions = [], restConditions = [] } = objectGroupBy(
417+
const { defaultConditions = [], restConditions = [] } = Object.groupBy(
434418
conditions,
435419
(condition) => {
436420
if (condition === 'default') {
@@ -445,7 +429,7 @@ const sortConditions = (conditions) => {
445429
}
446430

447431
const sortExports = onObject((exports) => {
448-
const { paths = [], conditions = [] } = objectGroupBy(
432+
const { paths = [], conditions = [] } = Object.groupBy(
449433
Object.keys(exports),
450434
(key) => (key.startsWith('.') ? 'paths' : 'conditions'),
451435
)
@@ -635,7 +619,7 @@ function sortPackageJson(jsonIsh, options = {}) {
635619

636620
if (Array.isArray(sortOrder)) {
637621
const keys = Object.keys(json)
638-
const { privateKeys = [], publicKeys = [] } = objectGroupBy(
622+
const { privateKeys = [], publicKeys = [] } = Object.groupBy(
639623
keys,
640624
(key) => (key[0] === '_' ? 'privateKeys' : 'publicKeys'),
641625
)

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)