Skip to content

[PoC] Migrate package manager from npm to pnpm#320100

Closed
ulugbekna wants to merge 1 commit into
microsoft:mainfrom
ulugbekna:agents/npm-to-pnpm-migration
Closed

[PoC] Migrate package manager from npm to pnpm#320100
ulugbekna wants to merge 1 commit into
microsoft:mainfrom
ulugbekna:agents/npm-to-pnpm-migration

Conversation

@ulugbekna
Copy link
Copy Markdown
Contributor

@ulugbekna ulugbekna commented Jun 5, 2026

Summary

Migrates the VS Code monorepo from npm to pnpm (pnpm@10.32.1 via corepack).

What changed

Workspace & manifests

  • Add pnpm-workspace.yaml with explicit members (mirroring build/npm/dirs.ts, not broad globs so manifest-only theme extensions and sim fixtures stay out) + an onlyBuiltDependencies allowlist for native/binary packages.
  • Root package.json: packageManager: pnpm@10.32.1, overridespnpm.overrides (pnpm selector syntax), all scripts converted npmpnpm.
  • build/, remote/, remote/web stay standalone (their own .npmrc with Node-runtime headers + own lockfile) outside the Electron-runtime workspace, so native modules build against the correct headers. Each gets its own pnpm.overrides + pnpm.onlyBuiltDependencies so lifecycle scripts still run under --ignore-workspace.

.npmrc files

  • node-linker=hoisted (packaging assumes a flat node_modules), pnpm peer settings; drop legacy-peer-deps.

Install orchestration & build scripts

  • Rewrite build/npm/preinstall.ts (pnpm guard), postinstall.ts (installs only the standalone dirs; root install is driven by pnpm install, no recursion), dirs.ts (standaloneDirs).
  • Update installStateHash.ts + build/azure-pipelines/common/computeNodeModulesCacheKey.ts to hash pnpm lockfiles/workspace.
  • build/lib/dependencies.ts uses pnpm list --prod ... --parseable. build/setup-npm-registry.ts now writes registry= into .npmrc (same CLI signature → Azure callers unaffected).

CI

  • GitHub Actions: corepack enable + pnpm install --frozen-lockfile (standalone build/ installs use --ignore-workspace).

Lockfiles

  • Remove the obsolete package-lock.json files; ignore pnpm-debug.log*. The pnpm-lock.yaml files must be generated and committed by CI.

Verification done locally

  • build type-check clean on all changed files.
  • pnpm-workspace.yaml parses; all 51 members resolve to real dirs.
  • All root scripts are npm-free.
  • Pre-commit hygiene hook passed.

Follow-ups (need CI / too heavy to verify in-session)

  • Generate & commit pnpm-lock.yaml (root) + standalone locks via pnpm install in CI.
  • Azure DevOps pipeline sweep: build/azure-pipelines/**/product-build-*-node-modules.yml, mixin-npm.ts, dependencies-check.yml — npm → corepack/pnpm + rework node_modules tarball caching toward the pnpm store / pnpm fetch.
  • Distro repo (.build/distro) coordination for the standalone installs.
  • Full native build-from-source + packaging E2E (ASAR, copy-from-node_modules).

⚠️ This is an AI-assisted migration intended as a starting point; the lockfile generation and Azure pipeline sweep are required before it can go green.

Copilot AI review requested due to automatic review settings June 5, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@ulugbekna ulugbekna marked this pull request as draft June 5, 2026 13:18
@ulugbekna ulugbekna changed the title Migrate package manager from npm to pnpm [PoC] Migrate package manager from npm to pnpm Jun 5, 2026
Migrate the VS Code monorepo from npm to pnpm.

- Add pnpm-workspace.yaml with explicit members (mirroring build/npm/dirs.ts)
  plus an onlyBuiltDependencies allowlist for native/binary packages.
- Root package.json: set packageManager=pnpm@10.32.1, convert overrides to
  pnpm.overrides (pnpm selector syntax), and convert all scripts npm->pnpm.
- Keep build/, remote/, remote/web as standalone installs (own .npmrc +
  lockfile, node runtime headers) outside the Electron-runtime workspace; give
  them their own pnpm.overrides + pnpm.onlyBuiltDependencies so native modules
  still build under --ignore-workspace.
- .npmrc files: node-linker=hoisted (packaging assumes a flat node_modules),
  pnpm peer settings, drop legacy-peer-deps.
- Rewrite install orchestration (preinstall.ts pnpm guard, postinstall.ts
  standalone-only sub-installs, dirs.ts standaloneDirs).
- Update hashing (installStateHash.ts, computeNodeModulesCacheKey.ts) and
  production-dependency listing (dependencies.ts) for pnpm; setup-npm-registry.ts
  now writes registry= into .npmrc instead of rewriting lockfiles.
- Update GitHub Actions to corepack enable + pnpm install --frozen-lockfile
  (standalone build/ installs use --ignore-workspace).
- Remove obsolete package-lock.json files (pnpm-lock.yaml to be generated and
  committed by CI); ignore pnpm-debug.log*.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ulugbekna ulugbekna force-pushed the agents/npm-to-pnpm-migration branch from e4e941d to c45749d Compare June 5, 2026 13:20
@ulugbekna ulugbekna closed this Jun 5, 2026
@ulugbekna ulugbekna reopened this Jun 5, 2026
@ulugbekna
Copy link
Copy Markdown
Contributor Author

Superseded by #320104 (branch pushed to upstream microsoft/vscode instead of a fork, as a draft).

@ulugbekna ulugbekna closed this Jun 5, 2026
@ulugbekna ulugbekna deleted the agents/npm-to-pnpm-migration branch June 5, 2026 13:23
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.

2 participants