Skip to content

Switch yarn to project-local cache so .pnp.cjs paths are stable across machines#158

Merged
dblock merged 3 commits into
masterfrom
improve-yarn-pnp
May 26, 2026
Merged

Switch yarn to project-local cache so .pnp.cjs paths are stable across machines#158
dblock merged 3 commits into
masterfrom
improve-yarn-pnp

Conversation

@moskvin

@moskvin moskvin commented May 17, 2026

Copy link
Copy Markdown
Contributor
  • Without a .yarnrc.yml, Yarn defaults to the user-level global cache (~/.yarn/berry/cache/), so .pnp.cjs ends up with packageLocation paths like ../../.yarn/berry/cache/... that are relative to wherever the repo was cloned. Every contributor whose checkout sits at a different depth from ~/ regenerates .pnp.cjs and produces a spurious diff.
  • Fix: add .yarnrc.yml with enableGlobalCache: false so the cache lives at ./.yarn/cache/ and .pnp.cjs records portable ./.yarn/cache/... paths. .yarn/ stays gitignored - contributors still run yarn install once after cloning, same as today. This is not a zero-installs change; no cache zips or unplugged binaries are committed.

@moskvin moskvin requested a review from Copilot May 17, 2026 05:10
@github-actions

github-actions Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Danger Report

No issues found.

View run

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make the Yarn Berry/PnP install artifacts portable by switching from Yarn’s global cache to a project-local cache, so .pnp.cjs no longer embeds machine-specific paths that break when the repo is cloned at a different directory depth.

Changes:

  • Add .yarnrc.yml to disable Yarn’s global cache (enableGlobalCache: false) so packages are stored under ./.yarn/cache.
  • Update .pnp.cjs to reference project-relative cache paths instead of ../../.yarn/berry/cache/....
  • Update .gitignore to ignore most of .yarn/ while explicitly tracking .yarn/cache and .yarn/unplugged for “zero-install” style checkouts, and add unplugged esbuild artifacts.

Reviewed changes

Copilot reviewed 1 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.yarnrc.yml Configures Yarn to use a project-local cache.
.pnp.cjs Rewrites cached package locations to ./.yarn/cache/... paths.
.gitignore Stops blanket-ignoring .yarn and instead tracks cache/unplugged directories.
.yarn/unplugged/@esbuild-darwin-arm64-.../README.md Adds unplugged (vendored) esbuild platform package docs.
.yarn/unplugged/@esbuild-darwin-arm64-.../package.json Adds unplugged (vendored) esbuild platform package metadata.
Files not reviewed (1)
  • .pnp.cjs: Language not supported

Comment thread .pnp.cjs
@moskvin moskvin force-pushed the improve-yarn-pnp branch from a6e6fa1 to 122d0c6 Compare May 17, 2026 05:17
@moskvin moskvin requested a review from dblock May 17, 2026 05:19

@dblock dblock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .zips, e.g. .yarn/cache/@esbuild-darwin-arm64-npm-0.25.12-2a5a9f9710-10c0.zip, should be removed, no? Or maybe I misunderstand the point of this change?

@moskvin

moskvin commented May 25, 2026

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-05-25 at 14 34 25 I have locally weird change - maybe I should just push the change instead of applying these changes - #161

@moskvin moskvin force-pushed the improve-yarn-pnp branch from 122d0c6 to cf545c0 Compare May 26, 2026 02:20
@moskvin

moskvin commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

The .zips, e.g. .yarn/cache/@esbuild-darwin-arm64-npm-0.25.12-2a5a9f9710-10c0.zip, should be removed, no? Or maybe I misunderstand the point of this change?

you're right, the zips were left over from experimenting with zero-installs - the path-stability fix doesn't need them, removing.

@moskvin moskvin changed the title Switch Yarn to project-local cache for portable zero-installs Switch yarn to project-local cache so .pnp.cjs paths are stable across machines May 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • .pnp.cjs: Language not supported

@moskvin moskvin requested a review from dblock May 26, 2026 02:27
@dblock dblock merged commit b494d6e into master May 26, 2026
12 checks passed
@dblock dblock deleted the improve-yarn-pnp branch May 26, 2026 14:39
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.

3 participants