User:Atomzamonday/sandbox

= Introduction = Yarn is a software packaging system developed in 2016 by Facebook for Node.js JavaScript runtime environment that provides speed, consistency, stability, and security as an alternative to npm (package manager). Yarn was created as a collaboration of Facebook, Exponent, Google, and Tilde to solve consistency, security, and performance problems with large codebases after Facebook was facing them. Yarn stands for “Yet Another Resource Negotiator”.

= Functionality = Yarn provided plug-in feature to extend the core-feature or abilities to make better and more structured work-flows.

Yarn not only included some plugins available to use by default but users can also write their own plugins.

Constraints
Yarn constraints allow you to automatically enforce rules for your dependencies or manifest fields in your project across entire scoped workspaces.

This feature is only available on Yarn Berry installation, run yarn plugin import constraints to add this feature.

Learn more about constraints: https://yarnpkg.com/features/constraints

Offline cache
The offline cache allows Yarn to automatically store downloaded dependencies and speed up the same dependencies package resolving with local cache next time.

This feature is a critical part of Zero-Installs and doesn't store more than a single file for each package, which makes it suitable for being stored within a repository.

Learn more about offline cache: https://yarnpkg.com/features/offline-cache

Plug'n'Play
Plug'n'Play allows us to run Node projects without node_modules folder, defining the way or location to resolve dependencies package files with the Plug-n-Play-control file. This feature is aimed to fix an unwell structured node_modules architecture and resulting in a faster NodeJs application start-up time.

Learn more about Plug'n'Play: https://yarnpkg.com/features/pnp

Plugins
Plugins let users extend the yarn features or abilities by writing plugins and inject them and Yarn will do so much more than it can do resulting in your work-flow process faster.

Plugins can add new resolvers, fetchers, linkers, commands, and can also register to some events or be integrated with each other, most features of Yarn are implemented through plugins, including yarn add and yarn install, which are also preinstalled plugins.

Learn more about plugins: https://yarnpkg.com/features/plugins

Protocols
Protocols let users define which protocol will be used to resolve certain packages, for example, git protocol is used for downloading a public package from a Git repository, patch protocol is used for creating a patched copy of the original package, semver protocol (semantic versioning) is used when installing a new package, it will be added to your package.json with a semver version range.

Learn more about protocols: https://yarnpkg.com/features/protocols

Release Workflow
Release Workflow automatically upgrades relative packages among monorepos workspaces when root packages are upgraded.

This feature is only available on Yarn Berry installation, run yarn plugin import version to add this feature.

Learn more about release workflow: https://yarnpkg.com/features/release-workflow

Workspaces
Workspaces allow multiple projects to work together in the same repository and automatically apply changes to other relatives when source code is modified, allowing installation of multiple packages by only running yarn install once to install all of them in a single pass.

Learn more about workspaces: https://yarnpkg.com/features/workspaces

Zero-Installs
Zero-Installs solve the needs of installation of packages when packages is required to install when the codes is just fresh fetched to local.

Learn more about zero-installs: https://yarnpkg.com/features/zero-installs

Installation and usage
You can use a local package manager like Homebrew in macOS or apt in Ubuntu to install Yarn and you can also use npm to install it as well.
 * Package manager must be installed as the same version on the environment to prevent accidental breaking changes between package dependencies versions.


 * Then, you need to upgrade to latest yarn version.


 * After you installed it, you can check if it exists in your local environment by running this command.

= Basic usages = See all the help. Initialise a new project. Install all of the dependencies Add a new dependency. Add a new dependency with a custom category Upgrade a dependency Remove a dependency Upgrade Yarn itself See more: https://yarnpkg.com/getting-started/usage = Advantages =


 * Yarn can install packages from local cache.


 * Yarn binds versions of the package strongly.


 * Yarn allows multiple packages installation simultaneously (parallel install)


 * Yarn’s user community is active and popular.


 * Yarn uses checksum for ensuring data integrity, while npm uses SHA-512 to check data integrity of the packages downloaded.

= Publishing packages = You must create an npm account and login to publish React components as an npm package.
 * Yarn installs packages in parallel, while npm installs one package at a time, so npm is basically slower than Yarn.

You can login from the npm website or command line using yarn login.

Creating a repository for your components is optional. = See also =


 * Npm (software)


 * Pnpm

= References =
 * JSPM