-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: adds a Recipes page to the docs (#2738)
* docs: adds a Recipes page to the docs * adds angular to pnp incompatibility list * add recipe * lint
- Loading branch information
1 parent
e42fc6f
commit f82502a
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
category: getting-started | ||
path: /getting-started/recipes | ||
title: "Recipes" | ||
description: Various cool things you can do with Yarn 2 | ||
--- | ||
|
||
## TypeScript + PnP quick start: | ||
|
||
- Initialize the repo using Yarn 2: | ||
```sh | ||
yarn init -2 | ||
``` | ||
|
||
- Add typescript and enable [VSCode integration](/getting-started/editor-sdks): | ||
```sh | ||
yarn add --dev typescript | ||
yarn dlx @yarnpkg/pnpify --sdk vscode | ||
``` | ||
|
||
- You can optionally enable [Yarn's TypeScript plugin](https://github.com/yarnpkg/berry/tree/master/packages/plugin-typescript), which helps manage `@types/*` dependencies automatically. | ||
```sh | ||
yarn plugin import typescript | ||
``` | ||
|
||
## Running a Yarn CLI command in the specified directory: | ||
|
||
- Starting a new library inside a monorepo directly, without manually creating directories for it. | ||
```sh | ||
yarn packages/my-new-lib init | ||
``` | ||
- Running an arbitrary command inside a specific workspace: | ||
```sh | ||
yarn packages/app tsc --noEmit | ||
``` | ||
|
||
## Hybrid PnP + node_modules mono-repo: | ||
|
||
You may sometimes need to use `node_modules` on just part of your workspace (for example, if you use Angular or React-Native). | ||
|
||
- Create a separate directory for the `node_modules` project. | ||
```sh | ||
mkdir nm-packages/myproj | ||
``` | ||
- Create an empty lockfile in the new project. Yarn uses lockfiles to locate the root of projects. | ||
```sh | ||
touch nm-packages/myproj/yarn.lock | ||
``` | ||
- Add a `.yarnrc.yml` file inside the new directory that enables `node_modules` just for it (`nm-packages/myproj/.yarnrc.yml`): | ||
```yml | ||
nodeLinker: node-modules | ||
``` | ||
- Add a PnP ignore pattern for this path in your main `.yarnrc.yml` at the root of your monorepo: | ||
```yml | ||
pnpIgnorePatterns: | ||
- ./nm-packages/** | ||
``` | ||
- You can now run `cd nm-package/myproj && yarn install` and the project will be isolated from your pnp root. |