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

[Docs] Inconsistency in yarn workspaces list --recursive documentation vs. actual behavior #6714

Open
WooWan opened this issue Mar 6, 2025 · 0 comments

Comments

@WooWan
Copy link

WooWan commented Mar 6, 2025

According to the documentation, --recursive option is described as:

Find packages via dependencies/devDependencies instead of using the workspaces field

However, based on code examination, it actually lists package dependents (packages that depend on the workspace), not its dependencies:

if (this.recursive)
for (const dependents of [...candidates].map(candidate => candidate.getRecursiveWorkspaceDependents()))
for (const dependent of dependents)
workspaces.add(dependent);

This inconsistency becomes more confusing when comparing with yarn workspaces foreach, which has different behavior depending on whether --since is used with --recursive:

if (this.recursive) {
if (this.since) {
log(`Option --recursive --since is set; recursively selecting all dependent workspaces`);
extra = new Set(selection.map(workspace => [...workspace.getRecursiveWorkspaceDependents()]).flat());
} else {
log(`Option --recursive is set; recursively selecting all transitive dependencies`);
extra = new Set(selection.map(workspace => [...workspace.getRecursiveWorkspaceDependencies()]).flat());
}

When both --recursive and --since are set in yarn workspaces foreach, it traverses dependents (like yarn workspaces list). But when only --recursive is set, it traverses dependencies instead.

This can be misleading for yarn newcomers(I am) who expect consistent behavior across commands. We should improve consistency and documentation to clearly reflect the actual behavior of each command.
While looking for previous discussions, I noticed this was mentioned in a yarn v4 issue, but I couldn't find any follow-up PRs or resolution.
It would be helpful to either update the documentation to correctly reflect the current behavior, or adjust the implementation to match the documented behavior.

@WooWan WooWan changed the title [Docs] Discrepency yarn workspaces list between docs and behaivor [Docs] Inconsistency in yarn workspaces list --recursive documentation vs. actual behavior Mar 7, 2025
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

No branches or pull requests

1 participant