Acquaintance
Yarn 2 (Berry) is a new release of the revolutionary and well-established Yarn package manager, including features such as Plug'n'Play, modular API extensibility, offline cache, and improved workspace support.
Plug'n'Play
Yarn PnP is a new feature that is included by default in Yarn 2. PnP dumps projects from the node_modules folder in favor of a .pnp.js file.
.pnp.js , , , Yarn . - node_modules, .
Yarn node_modules, , , .
, , , .
JavaScript Yarn Lerna .
, Yarn , , .
,
, Yarn 2 API, . β yarn add
yarn install
!
Yarn, , Yarn TypeScript, @types/packages
, yarn add
.
?
Yarn , .
Yarn, :
β― npm install -g yarn
( yarn --version
- 1.22.x
), :
β― mkdir my-app
β― cd my-app
βBerryβ β Yarn 2.
Yarn my-app
:
β― yarn set version berry
, !
, :
yarn init
β β β
yarn add <package> [--dev]
β ββ
yarn remove <package>
β β β
yarn up <package>
β ββ
, Yarn:
React.js Yarn- TypeScript
, , , , Yarn .
, Yarn Berry .
package.json TypeScript:
β― yarn init
β― yarn plugin import typescript
React:
β― yarn add react react-dom
β€ YN0000: β Resolution step
β€ YN0000: β Completed in 1s 932ms
β€ YN0000: β Fetch step
β€ YN0013: β loose-envify@npm:1.4.0
β€ YN0013: β object-assign@npm:4.1.1
β€ YN0013: β react-dom@npm:17.0.2
β€ YN0013: β react@npm:17.0.2
β€ YN0013: β scheduler@npm:0.20.2
β€ YN0000: β Completed in 0s 502ms
β€ YN0000: β Link step
β€ YN0000: β Completed
β€ YN0000: Done in 2s 503ms
@types/
!
What is the bottom line
The Yarn 1.x (Classic) branch has already officially moved into support status, which involves only fixing vulnerabilities.
All new features will be developed exclusively for Yarn 2, a version of which will be distributed through yarn set version
.
If Yarn doesnβt make friends with your IDE, there are a few things to install . Don't be bored!