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

Support excluding directories from workspaces #25226

Open
Yohe-Am opened this issue Aug 26, 2024 · 6 comments
Open

Support excluding directories from workspaces #25226

Yohe-Am opened this issue Aug 26, 2024 · 6 comments
Labels
suggestion suggestions for new features (yet to be agreed) workspaces

Comments

@Yohe-Am
Copy link

Yohe-Am commented Aug 26, 2024

A solution similar to how Cargo does it would be nice.

But also, it'd be great if it'd support excluding directories that might not contain a deno.json at the current time but might do so in the future. Or even better, exclude all of it's child directories as well.

Another nice feature might be to supports Cargo's semantics of excluding deno.json files that also declare their own workspace section. Currently, deno will error out with a message stating that the sub-workspace is not a member of the top dude.

@dsherret dsherret added suggestion suggestions for new features (yet to be agreed) workspaces labels Aug 26, 2024
@dsherret
Copy link
Member

dsherret commented Aug 26, 2024

I think this is only ever useful if wildcards are supported? Or are you talking about npm workspaces? I think npm workspaces support negated patterns.

@Yohe-Am
Copy link
Author

Yohe-Am commented Aug 27, 2024

I was referring to deno's feature actually. I suppose you mean wildcards for specifying members as well? That would be nice but the specific issue I encountered was related to exclusion.

Our repo has a tests/ directory with a number of deno.json based sub-projects that need to be shielded from the top level workspace. The suite itself generates a bunch more test deno.json when running so we can't manually specify the exclusion list at once.

There are workarounds but even slight support for exclusion is needed right now due to the error I mentioned.

Demonstration of the error:

/tmp/stuff via 🦕 v1.45.2
❯ lt                                                                                      at 03:03:07
 .
├──  bar
│   ├──  deno.json
│   └──  stuff.ts
├──  deno.json
└──  foo
    └──  deno.json

/tmp/stuff via 🦕 v1.45.2
❯ bat deno.json                                                                           at 03:03:08
───────┬──────────────────────────────────────────────────────────────────────────────────────────────
       │ File: deno.json
───────┼──────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "workspace": [
   3   │     "./foo"
   4   │   ]
   5   │ }
───────┴──────────────────────────────────────────────────────────────────────────────────────────────

/tmp/stuff via 🦕 v1.45.2
❯ deno run bar/stuff.ts                                                                   at 03:03:10
error: Config file must be a member of the workspace.
  Config: file:///tmp/stuff/bar/deno.json
  Workspace: file:///tmp/stuff/

@dsherret
Copy link
Member

Ah ok, so basically you'd like:

Another nice feature might be to supports Cargo's semantics of excluding deno.json files that also declare their own workspace section. Currently, deno will error out with a message stating that the sub-workspace is not a member of the top dude.

...since workspace members aren't included unless explicitly specified at the moment.

The suite itself generates a bunch more test deno.json when running so we can't manually specify the exclusion list at once.

If the test suite is generating files, you might want to have all that execute in temp directories. That will prevent your editor from reacting to all the file changes occurring in your cwd when running tests.

@Hajime-san
Copy link
Contributor

I also agree with this exclude option.
For more complex mixed Node.js and Deno projects, this option can avoid installing unnecessary package.json packages.
However, it seems that some npm packages may not work properly with this option, so I think users should set this option at their own risk.

@dsherret
Copy link
Member

Another nice feature might be to supports Cargo's semantics of excluding deno.json files that also declare their own workspace section. Currently, deno will error out with a message stating that the sub-workspace is not a member of the top dude.

By the way, I just thought about how to do this today. You can stop the ancestor directory search by adding the following to the child deno.json files:

{
  "workspace": []
}

Overall, given that, I'm not sure there's much use for this feature and it's really only necessary once there's wildcards, but in that case there will be negative patterns like npm.

@Yohe-Am
Copy link
Author

Yohe-Am commented Aug 27, 2024

Nice. Looks like the empty workspace section does indeed prevent inclusion in a parent workspace. I could have sworn I'd tried that but something must have gone wrong. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed) workspaces
Projects
None yet
Development

No branches or pull requests

4 participants
@dsherret @Hajime-san @Yohe-Am and others