Am I meant to commit yarn’s `.pnp.js` file?

I found this comment by Arcanis (the lead maintainer of Yarn) on an issue asking about what to include in a .gitignore. It may answer your question:

  • .yarn/plugins and .yarn/releases contain the Yarn releases used in the current repository (as defined by yarn set version). You will want to keep them versioned (this prevents potential issues if, say, two engineers use different Yarn versions with different features).

  • .yarn/unplugged should likely always be ignored, since it may contain native builds

  • .yarn/build-state.yml should likely be ignored as well, as it contains the build infos

    • If for some reason you version unplugged, it may make sense to keep build-state as well
  • .yarn/cache may be ignored, but you’ll need to run yarn install to regenerate it

    • Versioning it unlocks what we call Zero-Installs – it’s optional, though
  • .pnp.js (and potentially .pnp.data.json) are in the same boat as the cache. Add it to your repository if you keep your cache in your repository, and ignore it otherwise.

  • yarn.lock should always be stored within your repository (even if you develop a library)

So to summarize:

If you’re using Zero-Installs:

.yarn/unplugged
.yarn/build-state.yml

If you’re not using Zero-Installs:

.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*

Leave a Comment

tech