diff --git a/content/docs/techniques/web/package-manager/yarn.mdx b/content/docs/techniques/web/package-manager/yarn.mdx index e5f36c8..f6e17ff 100644 --- a/content/docs/techniques/web/package-manager/yarn.mdx +++ b/content/docs/techniques/web/package-manager/yarn.mdx @@ -6,31 +6,416 @@ preview: "Yarn" ## Yarn's Evolution Overview +### Yarn Classic + +Introduced by Facebook in 2016, Yarn aimed to solve some of the issues developers experienced with NPM. +NPM’s early versions lacked key features like lockfiles, which made dependency resolution inconsistent. +Yarn addressed these issues by ensuring that package versions and installation processes were predictable, especially in large teams where consistency matters. + +It focuses on speed, security, and reliability, introducing features like offline caching and deterministic installs (ensuring the same package versions are installed across machines). + +**Key Features:** + +- **Faster installs:** Yarn introduced parallel package downloads, reducing installation times. +- **Deterministic lockfiles:** The `yarn.lock` file ensures that the same dependencies are installed across all environments. +- **Offline support:** Yarn can cache packages, allowing offline installation. + +### Yarn Berry (Yarn 2+ or Yarn Modern) + +Yarn Berry, also known as Yarn 2 or Yarn Modern, represents a significant overhaul from Yarn Classic (Yarn 1), bringing improved performance, better workspace management, and a variety of new features. +Yarn Berry emphasizes security, performance, and modern workflows, particularly for larger projects and monorepos. + +**This Documentation will focus on Yarn Berry** + +**Key Features:** + +- **Zero-Installs:** Yarn Berry enables you to store dependencies in the .yarn/cache folder, which is committed to the repository, so you can clone the repository and start coding without running yarn install. +- **PnP (Plug’n’Play):** This feature removes the need for `node_modules`, reducing disk space usage and improving speed by resolving dependencies directly. +- **Better workspace management:** It handles monorepos more efficiently, with advanced workspace linking and dependency hoisting. +- **Improved plugin architecture:** With Yarn Berry, you can extend and customize the behavior by using or writing plugins. +- **Yarn Constraints:** You can define project-wide rules and ensure your code follows specific standards, improving overall consistency. + +**CLI commands:** + +- **Install dependencies:** `yarn install`. +- **Add package:** `yarn add `. +- **Remove package:** `yarn remove `. +- **Run scripts:** `yarn run