Background
We currently pin Yarn 3.6.4 (Berry) via corepack (packageManager in root package.json), with nodeLinker: node-modules. Yarn Berry v3 is end-of-life — the last v3 release (3.8.6) shipped in 2024 and receives no further updates. We should migrate to v4 to stay on a supported line.
This is dev-tooling only — no consumer impact. The published @sentry/react-native package (from packages/core) carries no packageManager field or yarn config; the packageManager field, yarn.lock, and .yarnrc.yml live at the repo root and are never part of the npm tarball. CI is already corepack-driven.
Why not just bump v3 → 3.8.6?
The intermediate bump to the last v3 release does not work in this repo. Yarn bundles @yarnpkg/plugin-compat, which auto-applies a patch to the typescript package (#~builtin<compat/typescript>) to support PnP. This patch is a line-based diff against TypeScript's internals, and each yarn release pins one revision of it.
- 3.8.6's bundled patch fails to apply to the modern TypeScript versions our workspaces use —
packages/core (~5.9.3), samples/react-native (5.8.3), samples/expo (~6.0.3) — with Cannot apply hunk #22. This is a recurring yarn issue (see berry#6189, #3722, #2952).
- The only way to make 3.8.6 install would be downgrading TypeScript repo-wide, which is a non-starter.
- Ironically, we're on
nodeLinker: node-modules, so the compat patch is unnecessary here — but yarn applies it regardless (berry#3275).
v4 ships an up-to-date patch revision that applies cleanly to TS 5.8/5.9/6.0, so it's actually the working path — verified locally with yarn@4.9.2.
One additional fix needed for v4
downlevel-dts@0.11.0 (our TS-3.8 type generator) depends on typescript@npm:next, which the lockfile froze to a nightly (5.7.0-dev.20240829). No compat patch — v3 or v4 — can patch a nightly build (ENOENT ... _tsc.js). Fixed with a one-line resolutions pin to stable:
"downlevel-dts@npm:0.11.0/typescript": "5.9.3"
With this, corepack yarn install completes cleanly on 4.9.2.
Scope of change
- Bump
packageManager to yarn@4.9.2 in root package.json
- Add the
downlevel-dts resolutions pin above
.yarnrc.yml picks up ~4 v4 default settings automatically
yarn.lock gets a large but mechanical format-bump diff (~14k lines: #~builtin → #optional!builtin, new checksum format)
- Pin CI Node to >= 18.12 (v4's floor; we run Node 18 unpinned today)
Notes
- v3 EOL is not urgent (v3 still works; even
sentry-javascript runs on the older Yarn Classic v1), but the migration is low-risk and worth doing.
Background
We currently pin Yarn 3.6.4 (Berry) via corepack (
packageManagerin rootpackage.json), withnodeLinker: node-modules. Yarn Berry v3 is end-of-life — the last v3 release (3.8.6) shipped in 2024 and receives no further updates. We should migrate to v4 to stay on a supported line.This is dev-tooling only — no consumer impact. The published
@sentry/react-nativepackage (frompackages/core) carries nopackageManagerfield or yarn config; thepackageManagerfield,yarn.lock, and.yarnrc.ymllive at the repo root and are never part of the npm tarball. CI is already corepack-driven.Why not just bump v3 → 3.8.6?
The intermediate bump to the last v3 release does not work in this repo. Yarn bundles
@yarnpkg/plugin-compat, which auto-applies a patch to thetypescriptpackage (#~builtin<compat/typescript>) to support PnP. This patch is a line-based diff against TypeScript's internals, and each yarn release pins one revision of it.packages/core(~5.9.3),samples/react-native(5.8.3),samples/expo(~6.0.3) — withCannot apply hunk #22. This is a recurring yarn issue (see berry#6189, #3722, #2952).nodeLinker: node-modules, so the compat patch is unnecessary here — but yarn applies it regardless (berry#3275).v4 ships an up-to-date patch revision that applies cleanly to TS 5.8/5.9/6.0, so it's actually the working path — verified locally with
yarn@4.9.2.One additional fix needed for v4
downlevel-dts@0.11.0(our TS-3.8 type generator) depends ontypescript@npm:next, which the lockfile froze to a nightly (5.7.0-dev.20240829). No compat patch — v3 or v4 — can patch a nightly build (ENOENT ... _tsc.js). Fixed with a one-lineresolutionspin to stable:With this,
corepack yarn installcompletes cleanly on 4.9.2.Scope of change
packageManagertoyarn@4.9.2in rootpackage.jsondownlevel-dtsresolutionspin above.yarnrc.ymlpicks up ~4 v4 default settings automaticallyyarn.lockgets a large but mechanical format-bump diff (~14k lines:#~builtin→#optional!builtin, new checksum format)Notes
sentry-javascriptruns on the older Yarn Classic v1), but the migration is low-risk and worth doing.