From 2e55dcf1300dfd46fcd0e0632fb45104ca51461f Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Wed, 18 Mar 2026 16:59:19 -0700 Subject: [PATCH] fix: default to ['.'] for workspacePackagePatterns when packages field is missing (#10996) Commit 6eedf828b removed the ['.'] fallback for workspacePackagePatterns when pnpm-workspace.yaml has no packages field. This caused findPackages to default to ['.', '**'], discovering ALL directories with package.json as workspace projects. This is the same regression that was previously reverted in 595cd414f (close #10571), reintroduced by #10127. Projects like cdxgen that use pnpm-workspace.yaml only for settings (e.g. minimumReleaseAge) without a packages field were broken because test data directories were picked up as workspace projects. close #10909 --- .changeset/fix-workspace-package-discovery.md | 6 ++++++ config/reader/src/index.ts | 2 +- .../pnpm-workspace.yaml | 1 + config/reader/test/index.ts | 15 +++++++++++++++ pnpm/test/recursive/misc.ts | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-workspace-package-discovery.md create mode 100644 config/reader/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml diff --git a/.changeset/fix-workspace-package-discovery.md b/.changeset/fix-workspace-package-discovery.md new file mode 100644 index 0000000000..ad35780c56 --- /dev/null +++ b/.changeset/fix-workspace-package-discovery.md @@ -0,0 +1,6 @@ +--- +"@pnpm/fs.find-packages": patch +"pnpm": patch +--- + +Fix a regression where `pnpm-workspace.yaml` without a `packages` field caused all directories to be treated as workspace projects. This broke projects that use `pnpm-workspace.yaml` only for settings (e.g. `minimumReleaseAge`) without defining workspace packages [#10909](https://github.com/pnpm/pnpm/issues/10909). diff --git a/config/reader/src/index.ts b/config/reader/src/index.ts index a8208b70c7..60b43f06db 100644 --- a/config/reader/src/index.ts +++ b/config/reader/src/index.ts @@ -408,7 +408,7 @@ export async function getConfig (opts: { if (pnpmConfig.workspaceDir != null) { const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir) - pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages + pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? ['.'] if (workspaceManifest) { addSettingsFromWorkspaceManifestToConfig(pnpmConfig, { configFromCliOpts, diff --git a/config/reader/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml b/config/reader/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml new file mode 100644 index 0000000000..4ff9cc2cbd --- /dev/null +++ b/config/reader/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml @@ -0,0 +1 @@ +minimumReleaseAge: 4320 diff --git a/config/reader/test/index.ts b/config/reader/test/index.ts index 34d1e218e5..7af8e2e586 100644 --- a/config/reader/test/index.ts +++ b/config/reader/test/index.ts @@ -815,6 +815,21 @@ test('reads workspacePackagePatterns', async () => { expect(config.workspacePackagePatterns).toEqual(['packages/*']) }) +test('workspacePackagePatterns defaults to ["."] when pnpm-workspace.yaml has no packages field', async () => { + const workspaceDir = path.join(import.meta.dirname, 'fixtures/workspace-yaml-without-packages') + process.chdir(workspaceDir) + const { config } = await getConfig({ + cliOptions: {}, + packageManager: { + name: 'pnpm', + version: '1.0.0', + }, + workspaceDir, + }) + + expect(config.workspacePackagePatterns).toEqual(['.']) +}) + test('setting workspace-concurrency to negative number', async () => { const workspaceDir = path.join(import.meta.dirname, 'fixtures/pkg-with-valid-workspace-yaml') process.chdir(workspaceDir) diff --git a/pnpm/test/recursive/misc.ts b/pnpm/test/recursive/misc.ts index 42d9bbe922..d619e6062c 100644 --- a/pnpm/test/recursive/misc.ts +++ b/pnpm/test/recursive/misc.ts @@ -286,6 +286,7 @@ test('recursive command with filter from config', async () => { fs.writeFileSync('package.json', '{}', 'utf8') writeYamlFileSync('pnpm-workspace.yaml', { + packages: ['*'], filter: ['project-1', 'project-2'], }) await execPnpm(['recursive', 'install'])