Skip to content
Status

SDKs

Switching default package manager to pnpm

Switching default package manager to pnpm

Prerequisite

Adding pnpm Support

  1. Open the GitHub Actions workflow file (e.g., .github/workflows/sdk-generation.yaml).
  2. Modify the generate job to include the pnpm_version input. This ensures pnpm is installed during the action.

Example Workflow File

name: Generate
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
"on":
workflow_dispatch:
inputs:
force:
description: Force generation of SDKs
type: boolean
default: false
set_version:
description: Optionally set a specific SDK version
type: string
jobs:
generate:
uses: speakeasy-api/sdk-generation-action/.github/workflows/workflow-executor.yaml@v15
with:
force: ${{ github.event.inputs.force }}
mode: pr
set_version: ${{ github.event.inputs.set_version }}
speakeasy_version: latest
working_directory: packages/sdk
pnpm_version: "9.19.4" # Specify the required pnpm version
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
npm_token: ${{ secrets.NPM_TOKEN_ELEVATED }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

(Optional) Verifying pnpm Installation

Ensure pnpm is used in the workflow by adding a step to verify its presence:

steps:
- name: Verify pnpm installation
run: pnpm --version

This outputs the installed pnpm version for confirmation during workflow execution.

Additional Notes

  • Use the same pnpm_version as used in local development for consistency.
  • Ensure any package.json files are compatible with pnpm. Run pnpm install locally to verify.

Using PNPM in Monorepos

When working with monorepos, pnpm offers several advantages including strict module resolution and efficient workspace management. To configure Speakeasy to use pnpm in your monorepo:

Local Development Configuration

Add the compileCommand configuration to your gen.yaml file:

typescript:
compileCommand:
- pnpm
- install

Workspace Configuration

Ensure your pnpm-workspace.yaml includes the SDK directory:

packages:
- "packages/*"
- "sdk/*" # Include your SDK location

Benefits for Monorepos

  • Strict module resolution: Prevents dependency confusion between packages
  • Efficient storage: Shared dependencies across workspace packages
  • Better workspace support: Built-in monorepo tooling

Related Guide

For comprehensive monorepo setup and troubleshooting tips, see our TypeScript Monorepo Tips guide.