Skip to content

feat!: drop support for Node 18 and 20 - #328

Open
cryptodev-2s wants to merge 4 commits into
migrate/swap-depcheck-for-knipfrom
migrate/drop-node-18-20
Open

feat!: drop support for Node 18 and 20#328
cryptodev-2s wants to merge 4 commits into
migrate/swap-depcheck-for-knipfrom
migrate/drop-node-18-20

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Replaces #324, which GitHub auto-closed as merged during a stack reorder when its head briefly became an ancestor of its base. The changes never reached main; this carries the same two commits.

Mirrors MetaMask/core#9976, the bottom of core's foundational stack.

Before After
engines.node ^18.18 || ^20.14 || >=22 ^22.14.0 || ^24
@types/node ~18.18.14 ^22.13.14
CI matrix 18, 20, 22 22, 24

constraints.pro is updated so yarn constraints enforces the new range. Core makes the @types/node bump in this same PR rather than with its TypeScript change, since the types track the supported runtime.

Position in the stack

This now sits below the ESM conversion (#323), so everything up to and including this PR is still a hybrid CJS/ESM build:

main → … → #322 → this → #323 (ESM only) → #325 (TypeScript)

That matters for testing. A preview build from here still resolves through main: ./dist/index.cjs with the require condition intact, so it can be consumed by metamask-extension as-is. Everything below the ESM cut can therefore be verified against a real downstream consumer before the breaking change lands.


Note

Medium Risk
Breaking engines change affects every downstream install and CI on Node 18/20; application logic changes are minimal aside from test assumptions.

Overview
Breaking: supported Node is now ^22.14.0 || ^24 (aligned with MetaMask core), replacing ^18.18 || ^20.14 || >=22.

That range is enforced in package.json engines, constraints.pro for yarn constraints, and the CI matrix in build-lint-test.yml (22 and 24 only). Dev typings move from @types/node ~18 to ^22, with lockfile updates.

Test and lint setup no longer assume Node 18: hashing.test.ts drops the webcrypto polyfill and semver gate, assuming globalThis.crypto on the new floor. ESLint comments for test files are updated to match Node 22+ behavior for the global crypto builtin.

Reviewed by Cursor Bugbot for commit b51551d. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​types/​node@​18.18.14 ⏵ 22.20.1100 +121008196100

View full report

@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The following preview build has been published:

@metamask-previews/utils@11.12.1-preview-c44fd50

Learn how to use preview builds in other projects.

@cryptodev-2s
cryptodev-2s removed this pull request from stack #329 September 9, 2026 11:46
@cryptodev-2s
cryptodev-2s force-pushed the migrate/drop-node-18-20 branch from c44fd50 to 08c239d Compare September 9, 2026 11:46
@socket-security

socket-security Bot commented Sep 9, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@cryptodev-2s
cryptodev-2s changed the base branch from migrate/pr2h-fix-tsd to migrate/swap-depcheck-for-knip September 9, 2026 11:47
@cryptodev-2s
cryptodev-2s added this pull request to stack #331 September 9, 2026 11:47
@cryptodev-2s
cryptodev-2s force-pushed the migrate/drop-node-18-20 branch 2 times, most recently from ced5e47 to 4f428cc Compare September 9, 2026 16:10
@cryptodev-2s
cryptodev-2s force-pushed the migrate/drop-node-18-20 branch from 4f428cc to 424c070 Compare September 9, 2026 16:32
@cryptodev-2s
cryptodev-2s force-pushed the migrate/drop-node-18-20 branch from 424c070 to 8f59757 Compare September 9, 2026 18:31
Mirrors MetaMask/core#9976, the bottom of core's foundational stack.

BREAKING: the supported range moves from ^18.18 || ^20.14 || >=22 to
^22.14.0 || ^24, the same range core adopts. The CI matrix drops to 22 and
24, and constraints.pro is updated to match.

This lands before the TypeScript and target/lib changes on purpose. Core
sequenced its stack Node, then ESM, then TypeScript, then target/lib, and
that order is a dependency chain rather than an arbitrary grouping: raising
the runtime floor first is what justifies each step above it, and emitting
a higher target is only defensible once the floor guarantees it.
Follows from the runtime floor moving to Node 22. Core makes the same bump
in the same PR as its Node drop (MetaMask/core#9976), rather than alongside
the TypeScript change, since the types track the supported runtime.
@cryptodev-2s
cryptodev-2s force-pushed the migrate/drop-node-18-20 branch from 8f59757 to 07bb86e Compare September 9, 2026 18:47
Follow up to removing the Node 18 polyfill in the same PR. The remaining
`webcrypto` usage was the other half of the same workaround:

  const originalSubtle = globalThis.crypto?.subtle ?? webcrypto.subtle;

The fallback only mattered when globalThis.crypto could be absent, which was
Node 18. The floor here is now ^22.14.0 || ^24, where the global is always
present, so this reads `globalThis.crypto.subtle` and the `crypto` import
goes with it.

All 12 tests still pass. The node-builtins disable is still required: with it
removed the rule still reports nine occurrences, because it treats the global
`crypto` as experimental until Node 23.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant