Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the workspace documentation #632

Merged
merged 1 commit into from
Sep 7, 2017
Merged

Adds the workspace documentation #632

merged 1 commit into from
Sep 7, 2017

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Sep 7, 2017

No description provided.

@Haroenv
Copy link
Member

Haroenv commented Sep 7, 2017

Deploy preview ready!

Built with commit 477929f

https://deploy-preview-632--yarnpkg.netlify.com


{% include vars.html %}

Workspace are a new way to setup your package architecture that's available by default starting from Yarn 1.0. It allows you to setup multiple packages in such a way that you only need to run `yarn install` once to install all of them in a single pass.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Workspace/Workspaces

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you only need to run yarn install once to install all of them in a single pass

you only need to run yarn install at the root, to install everything in a single pass.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can be installed from anywhere, actually, as long as you're in the workspace tree


### Why would you want to do this?

- Your dependencies can be linked together, which means that a workspace can depend on another and always use the most up-to-date version of it, without having to run `yarn install` again like with the `file:` protocol, and with better safety mechanisms than with `yarn link`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to split into two sentences:

Your dependencies can be linked together, which means a workspace can depend on another and use the latest version of it from the monorepo. This is also a safer mechanism than yarn link since yarn now keeps track of actual dependencies along with versions even if they are linked locally.


### Tips & Tricks

- The `workspaces` field is an array containing the paths to each workspace. Since it might be tedious to keep track of each of them, this field also accepts glob patterns!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be suggest the packages/* pattern which is pretty common?

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


Yarn's workspaces are the low-level primitives that tools like Lerna can (and [do](https://github.com/lerna/lerna/pull/899)!) use. They will never try to support the high-level feature that Lerna offers, but by implementing the core logic of the resolution and linking steps inside Yarn itself we hope to enable new usages and improve performances.

### Tips & Tricks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remembered: it is important to mention the following too:

  • Workspaces only works in private packages
  • You can disable workspaces via setting workspaces-experimental to false in .yarnrc


### How does it compare to Lerna?

Yarn's workspaces are the low-level primitives that tools like Lerna can (and [do](https://github.com/lerna/lerna/pull/899)!) use. They will never try to support the high-level feature that Lerna offers, but by implementing the core logic of the resolution and linking steps inside Yarn itself we hope to enable new usages and improve performances.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: improve performance

@arcanis
Copy link
Member Author

arcanis commented Sep 7, 2017

@Haroenv is there something to do for this page to appear on https://deploy-preview-632--yarnpkg.netlify.com/en/docs? It seems automatic since the code of this page is blank, but I don't see it appear :(

@Haroenv
Copy link
Member

Haroenv commented Sep 7, 2017

@Haroenv
Copy link
Member

Haroenv commented Sep 7, 2017

yes, seems like that data file needs to be filled for it to render correctly, see https://deploy-preview-632--yarnpkg.netlify.com/en/docs/workspaces

workspaces-experimental false
```

### Limitations & Caveheats
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: caveats

@arcanis arcanis merged commit 1c04a88 into master Sep 7, 2017
@raycohen
Copy link

raycohen commented Feb 8, 2018

The language

This is also a better mechanism than yarn link since it only affects your workspace tree rather than your whole system.

is a bit strong and could be interpreted as "yarn link should not be used". Is that intentional? I think a little rewording could help make it clear this benefit is useful when you are in a multi-package setup

@netcazean
Copy link

netcazean commented Jan 19, 2021

#632
#1108
#1107
#181
#1106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants