javascript - 我是否打算提交 yarn 的 `.pnp.js` 文件?

标签 javascript node.js git yarnpkg

Yarn 包括一个可选的 "Plug'n'Play" feature移动node_modules出项目目录。这样做会创建一个 .pnp.js文件,其中包含对硬盘驱动器上各种依赖路径的引用。

该文件是自动生成的,有几千行长,并且似乎引用了特定于运行 yarn install 的机器的路径。 .

.pnp.js意味着与其余代码一起提交?尽管该文件似乎无法提交,但我似乎找不到任何有关此的信息。什么是公认的最佳实践,为什么?

最佳答案

我找到了this comment by Arcanis (Yarn 的主要维护者)关于在 .gitignore 中包含什么内容的问题.它可能会回答你的问题:

  • .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.*

关于javascript - 我是否打算提交 yarn 的 `.pnp.js` 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58550439/

相关文章:

javascript - React - 动态更新新输入的总数

javascript - 将 dataURI 图像从 JavaScript 解析为 PHP

node.js - IISNode 执行无提示地失败

javascript - 将使用 nvm 在项目上设置默认 Node 版本的点文件?

GIT:是否可以从具有不同目录结构的不同存储库中选取文件或更改

image - Git push 卡在 POST git-receive-pack 上

git - Squash 直接在功能上提交,无需 rebase 或 merge

javascript - 在没有内存泄漏的情况下在adobe air中使用js进行长轮询

javascript - 如何使用jquery获取html元素id

javascript - 如何在Javascript中异步使用对象?