Add Yarn and Pnpm workspaces support
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
This is an issue transferred from the CommunityToolkit repo. (CommunityToolkit/Aspire#1082)
Currently, the Javascript hosting extension adds support for turbo and nx workspace. This allows a global installation step for all apps in the same monorepo and avoids conflicts with multiple concurrent installs, for instance.
Two more kinds of javascript workspace managers could be added with the same principle: [Yarn workspace](https://yarnpkg.com/features/workspaces) and [pnpm workspace](https://pnpm.io/workspaces).
These two new workspaces are related to a specific package manager. So, creating a new yarn/pnpm workspace could also set the corresponding package manager for all related apps.
For yarn workspace, we could allow [focused install](https://yarnpkg.com/features/workspaces#focused-installs) but it's probably out of scope of this request and could be added in a follow-up issue/PR.
### Describe the solution you'd like
We can reuse the flow of turbo workspace in an apphost without the `WithPackageManagerLaunch` method.
```csharp
// Yarn
var yarnWorkspace = builder.AddYarnWorkspaceApp("yarn-demo");
yarnWorkspace.AddApp("yarn-web", filter: "web")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();
yarnWorkspace.AddApp("yarn-docs", filter: "docs")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();
// pnpm
var pnpmWorkspace = builder.AddPnpmWorkspaceApp("pnpm-demo");
pnpmWorkspace.AddApp("pnpm-web", filter: "web")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();
pnpmWorkspace.AddApp("pnpm-docs", filter: "docs")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();
```
In the CT repo, nx and yarn app are already `JavaScriptAppResource`. The workspace resource is more a virtual resource that manages dependencies install (1 per workspace). I think all workspace resource can share a common interface across all implementation. This could make integrations easier for more workspace manager.
### Additional context
This issue is related with this discord discussion: https://discord.com/channels/1361488941836140614/1438609740140904448
And here is a proposal PR inside the CT repo: https://github.com/CommunityToolkit/Aspire/pull/1110
Contributor guide
Assessment
This issue has not been assessed yet.