chore: Modernize codebase to node 22#40535
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
Important Review skippedToo many files! This PR contains 158 files, which is 8 over the limit of 150. To get a review, narrow the scope: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (158)
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #40535 +/- ##
===========================================
- Coverage 69.74% 69.66% -0.08%
===========================================
Files 3322 3322
Lines 122773 122775 +2
Branches 21870 21896 +26
===========================================
- Hits 85623 85533 -90
- Misses 33807 33885 +78
- Partials 3343 3357 +14
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ae42aba to
88c3f4c
Compare
88c3f4c to
faef962
Compare
Unlocks Node 22 built-ins (Object.hasOwn, toSorted, findLast, etc.). Target kept at es2020 to preserve class-field semantics.
- authorization.getRoles: `.sort` → `.toSorted` (no in-place mutation)
- SignalProcessor.reactToUnknownCall: `Promise.all + .catch(()=>null)` → `Promise.allSettled`
- EmojiCustom.findByNameOrAlias / OmnichannelTranscript: literal-pattern `.replace(/x/g, ...)` → `.replaceAll('x', ...)`
6 server-side call sites drop the uuid lib in favor of Node's built-in
randomUUID(). Federation Settings also collapses the new RegExp('-','g')
into .replaceAll('-', '_').
Sweep across server-side packages: prefix `fs`, `path`, `crypto`, `stream`, `http`, `util`, `events` and other Node builtins with the `node:` protocol. Skipped client widget code under `packages/livechat/src/` and compiled apps-engine output.
faef962 to
04865bf
Compare
|
/jira CORE |
Proposed changes (including videos or screenshots)
⏺ Adopt Node 22 / modern ES built-ins across server code
The shared @rocket.chat/tsconfig/server.json was pinned to lib: ["es2020"], even though every server package runs on Node 22. That mismatch hid ES2022/2023 APIs from
TypeScript and forced older idioms. Bumping only lib (target stays at es2020 to preserve class-field semantics) is a strict superset — no emitted JS changes — and is
the prerequisite for the rest of the commits.
ES2022's Object.hasOwn(obj, key) is the standardized replacement for obj.hasOwnProperty(key). It avoids the prototype-pollution / shadowing footgun and works on
null-prototype objects (Object.create(null)) without the ugly Object.prototype.hasOwnProperty.call(...) workaround. Mechanical swap, identical semantics.
Six call sites used the uuid package solely to mint a random v4 UUID. Node has provided crypto.randomUUID() since 14.17 with identical RFC 4122 output and a more
specific return type. The federation Settings.ts site also collapses an old replace(new RegExp('-', 'g'), '') into .replaceAll('-', '').
Sweep across 151 server-side files: from 'fs' → from 'node:fs', etc. Two motivations:
short-circuits resolution and refuses to find an imposter.
Issue(s)
Steps to test or reproduce
Further comments
Task: CORE-2204