Skip to content

Add Yarn and Pnpm workspaces support #1082

@vsantele

Description

@vsantele

Related to an existing integration?

Yes

Existing integration

Hosting.JavaScript.Extensions

Overview

Currently, the Javascript hosting extension adds support for turbo and nx workspace. This allows a global install 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 and pnpm workspace.

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 but it's probably out of scope of this request and could be added in a follow-up issue/PR.

Usage example

We can reuse the flow of turbo workspace in a apphost without the WithPackageManagerLaunch method.

// 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();

Breaking change?

No

Alternatives

The main pain point is the concurrent install for each app added in the apphost but sharing the same lock file. An alternative could be to only run the install step for one app and disable it for the others. Or create an external pnpm/yarn install command in the apphost with .WithPnpm(install: false); set for all apps.

Additional context

This issue is related with this discord discussion: https://discord.com/channels/1361488941836140614/1438609740140904448

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions