Skip to content

Commit

Permalink
docs: adds a Recipes page to the docs (#2738)
Browse files Browse the repository at this point in the history
* docs: adds a Recipes page to the docs

* adds angular to pnp incompatibility list

* add recipe

* lint
  • Loading branch information
andreialecu authored Apr 27, 2021
1 parent e42fc6f commit f82502a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/gatsby/content/features/plugnplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ The following tools unfortunately cannot be used with pure Plug'n'Play install (

| <div style="width:150px">Project name</div> | Note |
| --- | --- |
| Angular | Follow [angular/angular-cli/#16980](https://github.com/angular/angular-cli/issues/16980) |
| Flow | Follow [yarnpkg/berry#634](https://github.com/yarnpkg/berry/issues/634) |
| React Native | Follow [react-native-community/cli#27](https://github.com/react-native-community/cli/issues/27) |
| Pulumi | Follow [pulumi/pulumi#3586](https://github.com/pulumi/pulumi/issues/3586) |
Expand Down
58 changes: 58 additions & 0 deletions packages/gatsby/content/getting-started/recipes.md
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.

0 comments on commit f82502a

Please sign in to comment.