Repository navigation
fix(preferred-pm): detect pnpm via pnpm-workspace.yaml - #238
Merged
zkochan merged 1 commit intoSep 27, 2026
Merged
Conversation
The README documents that pnpm is preferred inside a pnpm workspace, but the directory walk only searched for pnpm-lock.yaml. Repositories that don't commit a lockfile (e.g. `lockfile: false`) were not detected as pnpm projects, so tools like `@pnpm/prepare-package` fell back to npm when preparing them as git deps. Also search up the tree for pnpm-workspace.yaml (required by pnpm v10+ for workspace/config). The "prefer pnpm inside a pnpm workspace" test now copies the fixture to a temp dir so it can't pass off this monorepo's own pnpm-lock.yaml. Fixes zkochan#197 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
3 of 4 tasks
4 of 5 tasks
zkochan
pushed a commit
to xiechimon/pnpm
that referenced
this pull request
Sep 25, 2026
A pnpm workspace is defined by pnpm-workspace.yaml, and committing a lockfile is optional (lockfile: false). detect_preferred_pm only sniffed pnpm-lock.yaml, so a git-hosted dependency that is a pnpm workspace with no committed lockfile fell through to npm. prepare_package then ran the install stage with npm, which honours the dependency's own .npmrc ignore-scripts and skips the build, leaving no dist/. Consult the manifest once every lockfile has had its say, so it breaks only the no-lockfile tie: a dependency that ships a lockfile has named what installs it, and that is stronger evidence than a config file. This is the precedence preferred-pm uses, consulting the manifest in its fallback stage (zkochan/packages#238), which keeps the two stacks aligned. Refs pnpm#14011
zkochan
pushed a commit
to pnpm/pnpm
that referenced
this pull request
Sep 25, 2026
A pnpm workspace is defined by pnpm-workspace.yaml, and committing a lockfile is optional (lockfile: false). detect_preferred_pm only sniffed pnpm-lock.yaml, so a git-hosted dependency that is a pnpm workspace with no committed lockfile fell through to npm. prepare_package then ran the install stage with npm, which honours the dependency's own .npmrc ignore-scripts and skips the build, leaving no dist/. Consult the manifest once every lockfile has had its say, so it breaks only the no-lockfile tie: a dependency that ships a lockfile has named what installs it, and that is stronger evidence than a config file. This is the precedence preferred-pm uses, consulting the manifest in its fallback stage (zkochan/packages#238), which keeps the two stacks aligned. Refs #14011 (the detection half; the v11 side lands via a preferred-pm bump and the suggested CLI override needs its own design)
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #197.
Problem
The README states "Inside a pnpm workspace, pnpm is preferred", but the directory walk only searched for
pnpm-lock.yaml:A pnpm workspace is defined by
pnpm-workspace.yaml, and committing a lockfile is optional — repos can setlockfile: false. Such a project is not detected as pnpm. This bites tools built onpreferred-pm:@pnpm/prepare-packagedoesconst pm = (await preferredPM(gitRootDir))?.name ?? 'npm', so when it prepares a git-hosted dependency that is a lockfile-less pnpm project, it falls back to npm — which then honours that project's.npmrcignore-scripts=trueand skips theprepare/build, leaving nodist/.As #197 notes, the existing
prefer pnpm inside a pnpm workspacetest only passes because it runs inside this monorepo, sofindUp('pnpm-lock.yaml')climbs up and finds the monorepo's own lockfile — the fixture'spnpm-workspace.yamlis never consulted. Delete the monorepo lockfile and the test fails.Change
index.js: the directory walk also looks forpnpm-workspace.yaml, matching the documented behaviour and pnpm v10+ (wherepnpm-workspace.yamlis required for workspace/config).test/index.js: theprefer pnpm inside a pnpm workspacetest now copies the fixture to a temp dir (same pattern as the Yarn/npm workspace tests) so detection must come from the fixture'spnpm-workspace.yaml, not an ancestor lockfile. Verified it fails without theindex.jschange and passes with it.All 11 tests pass and
standardis clean.