• Uncategorized

Facebook officially released JavaScript package manager Yarn 1.0

Facebook last week officially released JavaScript package manager Yarn 1.0.

Facebook says there are 175,000 projects on GitHub. With Yarn, many big and small companies and the majority of open source communities are using Yarn, and the number of packages downloaded by Yarn each month is close to 3 billion. In addition, Yarn is now pre-installed in such as  CircleCITravis CI  and  AppVeyor these mainstream integrated platform.

Yarn has excellent scalability and can support thousands of direct or indirect package dependencies. Yarn is designed to ensure stability, flexibility and high performance. Based on these principles, Yarn 1.0 brings more new features and hopes to help the Yarn community develop faster and build better projects.

Yarn 1.0 is a new feature worthy of attention

Yarn Workspace (Yarn Workspaces)

More and more technology companies are beginning to adopt code-based control (mono-repository – to facilitate cross-project sharing code, while avoiding dependence on synchronization issues) for code control, this model is gradually being open source community and some small companies adopted The

As a result, Yarn adds a new feature – the workspace. The workspace automatically collects all dependencies from multiple packages.json and installs them at once. The project root directory will generate a separate yarn.lock to lock the files. In addition, if there is a dependency between multiple workspaces, Yarn creates links for them so that all items can always share the latest code.

Automatically merge the yarn.lock file (Auto-merging of lockfiles)

Multiple developers in the development of the same project may need to update the package dependencies, resulting in yarn.lock file conflict. If there are only one or two conflicts, you can solve it manually, but if the number of conflicts is large, resolving conflicts can turn into a very troublesome thing.

Thus, Yarn provides the ability to automatically merge the yarn.lock file to resolve the problem of conflict. By running the commandyarn install you can trigger the merge if the merge is successful, the new non-conflicting yarn.lock file will be saved to disk.

Future plan

Facebook said the future of Yarn will achieve the following goals:

  • Using Yarn to publish packages: Publishing new packages usually requires creating the correct update log, performing the correct semantics version control, synchronizing the version of the related project, and requiring frequent manual or scripting to accomplish many other steps. Is it better if Yarn can accomplish these things for the package publisher?
  • Package security: When adding new packages or upgrading old packages, the security of the package is also a very important factor to consider. Yarn will work with npm to bring two-factor authentication to Yarn.

For more updated instructions, please check the release page.

Download: https://github.com/yarnpkg/yarn/releases