Skip to content

fix: restore default workspace pattern when packages field is missing#10573

Open
ryo-manba wants to merge 2 commits intomainfrom
fix/workspace-patterns-default
Open

fix: restore default workspace pattern when packages field is missing#10573
ryo-manba wants to merge 2 commits intomainfrom
fix/workspace-patterns-default

Conversation

@ryo-manba
Copy link
Copy Markdown
Member

Closes #10571

Restore the ['.'] fallback for workspacePackagePatterns when pnpm-workspace.yaml exists but has no packages field. Without this, findPackages defaults to ['.', '**'] and scans all subdirectories, breaking --frozen-lockfile.

The fallback is only applied when the manifest is not null, to keep #10520 working.

@ryo-manba ryo-manba marked this pull request as ready for review February 8, 2026 10:35
@ryo-manba ryo-manba requested a review from zkochan as a code owner February 8, 2026 10:35
Copilot AI review requested due to automatic review settings February 8, 2026 10:35
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.

Pull request overview

Restores the historical ['.'] fallback for workspacePackagePatterns when pnpm-workspace.yaml exists but lacks a packages field, preventing findPackages from defaulting to ['.', '**'] and scanning the entire tree (which can destabilize --frozen-lockfile).

Changes:

  • Update getConfig() to default workspacePackagePatterns to ['.'] when a workspace manifest exists but has no packages.
  • Adjust an existing recursive test fixture to explicitly set packages in pnpm-workspace.yaml.
  • Add a changeset documenting the bugfix for --frozen-lockfile in this scenario.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
config/config/src/index.ts Implements the ['.'] fallback for workspacePackagePatterns when packages is missing but a manifest exists.
pnpm/test/recursive/misc.ts Updates the test workspace manifest to include packages, aligning with the restored default behavior.
.changeset/petite-laws-share.md Adds release notes for the patch fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 412 to 415
const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir)

pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages
pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? (workspaceManifest ? ['.'] : undefined)
if (workspaceManifest) {
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

workspaceManifest may be a non-null object without a packages field (e.g. {} or a manifest that only contains other settings). In that case this sets workspacePackagePatterns to ['.'], which makes pnpm treat the repo as a workspace with only the root package. For recursive run/exec/add/test this can result in the workspace root being excluded by default (see the config.workspacePackagePatterns && !config.includeWorkspaceRoot logic), leading to "No projects matched the filters" in what is effectively a single-project repo. Consider avoiding setting workspacePackagePatterns to ['.'] for manifests that don’t define packages (or alternatively ensuring the workspace root is included when the computed patterns are only ['.']).

Copilot uses AI. Check for mistakes.
Comment on lines +414 to 415
pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? (workspaceManifest ? ['.'] : undefined)
if (workspaceManifest) {
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

This change restores a subtle defaulting behavior that affects workspace discovery and lockfile determinism, but there’s no direct regression test that asserts the new fallback (workspacePackagePatterns => ['.'] when pnpm-workspace.yaml exists without packages) prevents scanning subdirectories. Adding a targeted test (config unit test or pnpm integration test) for a workspace manifest without packages and a nested package.json would help prevent future regressions.

Copilot uses AI. Check for mistakes.
@zkochan
Copy link
Copy Markdown
Member

zkochan commented Feb 9, 2026

These rules are confusing and aren't covered with tests. I can't risk it on v10 branch. I am reverting the previous fix: #10578

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.

Lockfile changed between 10.28.2 and 10.29.1 for some packages

3 participants