Skip to content

Migrate Yarn 1 → Yarn 4 (Berry), nodeLinker node-modules - #2069

Merged
jthiller merged 1 commit into
mainfrom
chore/yarn-4-migration
Jun 6, 2026
Merged

jthiller merged 1 commit into
mainfrom
chore/yarn-4-migration

Conversation

@jthiller

@jthiller jthiller commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ Do not merge until a Cloudflare preview build on this branch is confirmed green. That's the one residual that can't be tested locally (see below).

What & why

Migrates the toolchain from Yarn 1.22.21 → Yarn 4.16.0 with the node-modules linker.

The [email protected] pin (commit 66de0ed) existed solely to dodge YN0028: Cloudflare's default image runs Yarn 4 + Node 22, which refused an immutable install against our Yarn-1 lockfile because it "required migration." A Yarn-4-native lockfile needs no migration, so the immutable install becomes a clean no-op — removing the reason for the pin and unblocking the modern toolchain.

Changes (5 files)

  • package.json → "packageManager": "[email protected]".
  • .yarn/releases/yarn-4.16.0.cjs (2.9 MB) — pinned binary, committed.
  • .yarnrc.yml — exactly 3 keys:
    nodeLinker: node-modules
    yarnPath: .yarn/releases/yarn-4.16.0.cjs
    enableScripts: true
  • yarn.lock → Yarn 4 native format (__metadata version: 10). The ~29k-line diff is the one-time v1→v4 format migration, not a dependency change (proven below).
  • .gitignore → official non-Zero-Install block (commit .yarn/releases; ignore .yarn/cache, .yarn/install-state.gz, .pnp.*).

Why these settings

  • nodeLinker: node-modules is load-bearing — Yarn 4 defaults to PnP, which breaks @docusaurus/theme-mermaid (#10645, closed not-planned) and @docusaurus/faster (#10787). node-modules produces a standard tree, so mermaid, the custom configureWebpack/ProvidePlugin, and faster's Rspack/SWC all resolve normally.
  • enableScripts: true — Yarn 4 defaults to false; this lets the Solana native addons (bigint-buffer/bufferutil/utf-8-validate) build as they did under Yarn 1 (they have pure-JS fallbacks regardless).

Verification — proven locally (Node 22.22.3, Yarn 4.16.0)

  • yarn install --immutable under CI=true YARN_ENABLE_IMMUTABLE_INSTALLS=true (the form Cloudflare runs) → exit 0, no YN0028, lockfile SHA-256 byte-for-byte unchanged before/after.
  • node scripts/build-redirects.mjs && yarn docusaurus build → [SUCCESS], all 71 HTML pages + build/llms.txt, zero module-resolution / mermaid-PnP errors.

Reviewer note

.yarnrc.yml must contain only the 3 keys above. A local yarn install on some machines transiently injects approvedGitRepositories: ['**'] / npmMinimalAgeGate: 0 (a machine-level Yarn artifact, also seen on the feat/jupiter-tokens-to-rent branch) — those loosen security and must not ship. Confirmed they are not present here and don't re-appear on a clean immutable install.

Cloudflare gate (the only untested residual)

CF v3 image = Yarn 4.9.1 / Node 22.16.0 and ignores yarn.lock/engines/packageManager for version selection. The committed yarnPath makes CF self-redirect to 4.16.0 (4.9.1 also reads a 4.x lockfile fine). .nvmrc already pins Node 22.22.3. Optionally set YARN_VERSION=4.16.0 in Pages settings as belt-and-suspenders. Please confirm the preview deploy builds 71 pages before merging.

🤖 Generated with Claude Code

Cloudflare's default build image runs Yarn 4 + Node 22, which refused an
immutable install against our Yarn-1 lockfile (YN0028) -- the reason the
toolchain was pinned to [email protected]. A Yarn-4-native lockfile needs no
migration, so that immutable install becomes a no-op and passes.

- packageManager -> [email protected]; commit .yarn/releases/yarn-4.16.0.cjs and
  pin it via .yarnrc.yml yarnPath so any 'yarn' invocation (incl. CF's)
  self-redirects to 4.16.0 regardless of the image's bundled version.
- .yarnrc.yml: nodeLinker: node-modules (REQUIRED -- PnP breaks
  @docusaurus/theme-mermaid, meta/docusaurus#10645, and @docusaurus/
  faster #10787), plus enableScripts: true so the Solana native addons
  (bigint-buffer/bufferutil/utf-8-validate) build as they did under Yarn 1.
- yarn.lock migrated to Yarn 4 native format (__metadata version: 10). The
  large diff is the one-time v1->v4 format change, not a dependency change.
- .gitignore: official non-Zero-Install block (commit .yarn/releases; ignore
  .yarn/cache, .yarn/install-state.gz, .pnp.*).

Verified on Node 22.22.3 + Yarn 4.16.0:
- 'yarn install --immutable' under CI=true / YARN_ENABLE_IMMUTABLE_INSTALLS=
  true (the form Cloudflare runs) exits 0 with the lockfile checksum
  byte-for-byte unchanged -- no YN0028.
- Production build (node scripts/build-redirects.mjs && docusaurus build)
  generates all 71 pages with no module-resolution or mermaid-PnP errors.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying heliumdocs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 42a70b0
Status: ✅  Deploy successful!
Preview URL: https://21cc8f0e.heliumdocs.pages.dev
Branch Preview URL: https://chore-yarn-4-migration.heliumdocs.pages.dev

View logs

@jthiller
jthiller merged commit 436f4a8 into main Jun 6, 2026
1 check passed
@jthiller
jthiller deleted the chore/yarn-4-migration branch June 6, 2026 00:42
jthiller added a commit that referenced this pull request Jun 6, 2026
The repo migrated to Yarn 4 (Berry) managed by Corepack (#2069), so the
setup docs were stale.

- CLAUDE.md Local Development: npm install/run -> nvm use + corepack enable +
  yarn install/start/build; prettier invoked via 'yarn dlx'.
- README Requirements: replace the stale 'Node >= 10.15.1 / Yarn >= 1.5' with
  a pointer to .nvmrc for Node and Corepack-managed Yarn 4. Referencing .nvmrc
  (rather than hardcoding a version) keeps the docs correct across Node bumps.
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