Skip to content

Optimize yarn workspace discovery #1430

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

andrian-sevastyanov
Copy link
Contributor

No description provided.

@@ -90,12 +90,7 @@ private ExcludedIncludedWildcardFilter deriveExcludedIncludedWildcardFilter() {

@NotNull
private YarnWorkspaces collectWorkspaceData(File dir) throws IOException {
Collection<YarnWorkspace> curLevelWorkspaces = packageJsonFiles.readWorkspacePackageJsonFiles(dir);
Collection<YarnWorkspace> allWorkspaces = new LinkedList<>(curLevelWorkspaces);
for (YarnWorkspace workspace : curLevelWorkspaces) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is unnecessary to try to find nested workspaces.

Nested workspaces are not supported at this time.

From https://classic.yarnpkg.com/lang/en/docs/workspaces/

Copy link
Contributor

Choose a reason for hiding this comment

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

That link looks like it covers yarn classic (1.x?). At the top there is a link to I believe more current documentation. It does seem like nested workspaces are supported in more recent versions? Seems like we support up to 4.1 so nested workspaces might be supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't found any mention of nested workspaces in later documentation, so I did an experiment with Yarn 4.1.0:

  1. Create a project with workspaces having 3 levels (root points to workspace sub, which points to workspace sub1, which points to workspace sub2)
  2. In package sub2 package.json specify a dependency
  3. At root level run yarn install
  4. Now yarn.lock contains dependency from sub2

So, it seems like we do need to take nested workspaces into account for at least some versions. Furthermore, we probably need to do this recursively instead of at just two levels as we've been doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed it back to two levels for now. We can explore doing more going forward.

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.

2 participants