Skip to content

Be more aware of the workspace during clean #7752

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 6 commits into
base: master
Choose a base branch
from

Conversation

nojaf
Copy link
Member

@nojaf nojaf commented Aug 2, 2025

This is an attempt to drive the conversation at #7707

In case of clean, we already do an upward traversal to find a root rescript json.
I'm adding some logic to check if the parent rescript json contains the current rescript json in "dependencies" (or "dev-dependencies").

If we did find a link, we would only remove the files from the current project and not everything.

Consider https://github.com/nojaf/rescript-kaplay/blob/main/packages/rescript-kaplay/rescript.json

We already find https://github.com/nojaf/rescript-kaplay/blob/d38649fcd409c174c39b31488f790e036f3b0a20/rescript.json#L8

If that name matches root_package (in the code, a bit confusing name) is "@nojaf/rescript-kaplay", so we only need to remove those files.

Files from https://github.com/nojaf/rescript-kaplay/blob/main/packages/samples/rescript.json are unaffected.

If we were to clean from the repo root, root_config would be the well the root package and everything gets cleaned.

Copy link
Member Author

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Let me know if something doesn't make any sense.

Copy link

pkg-pr-new bot commented Aug 2, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7752

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7752

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7752

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7752

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7752

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7752

commit: 7b84cb4

@nojaf
Copy link
Member Author

nojaf commented Aug 4, 2025

I think it might make sense to rethink the format command as well.

Would it not be more consistent if we format either:

  • a specific file argument like format Foo.res
  • Format all projects in case of a monorepo when invoked at the root.
  • Format a specific project only when it is part of a workspace, but invoked at the project level and not the root.

The --all flag seems a bit off compared to clean.

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.

1 participant