Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: install peerDeps which is not optional on headless install #5243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/calm-windows-study.md
@@ -0,0 +1,7 @@
---
"@pnpm/filter-lockfile": patch
"@pnpm/headless": patch
"pnpm": patch
---

Auto install peer dependencies when auto-install-peers is set to true and the lockfile is up to date [#5213](https://github.com/pnpm/pnpm/issues/5213).
Expand Up @@ -161,10 +161,7 @@ function pkgAllDeps (
...pkgSnapshot.dependencies,
...(opts.include.optionalDependencies ? pkgSnapshot.optionalDependencies : {}),
})
.map(([pkgName, ref]) => {
if (pkgSnapshot.peerDependencies?.[pkgName]) return null
return dp.refToRelative(ref, pkgName)
})
.map(([pkgName, ref]) => dp.refToRelative(ref, pkgName))
.filter((nodeId) => nodeId !== null) as string[]

pkgAllDeps(ctx, nextRelDepPaths, installable, opts)
Expand Down
@@ -0,0 +1 @@
auto-install-peers=true
@@ -0,0 +1,7 @@
{
"name": "reinstall-peer-deps",
"version": "1.0.0",
"devDependencies": {
"@pnpm.e2e/abc": "1.0.0"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/headless/test/index.ts
Expand Up @@ -528,6 +528,16 @@ test('installation of a dependency that has a resolved peer in subdeps', async (
expect(project.requireModule('pnpm-default-reporter')).toBeTruthy()
})

test('install peer dependencies that are in prod dependencies', async () => {
const prefix = f.prepare('reinstall-peer-deps')

await headless(await testDefaults({ lockfileDir: prefix }))

const project = assertProject(prefix)

await project.has('.pnpm/@pnpm.e2e+peer-a@1.0.1/node_modules/@pnpm.e2e/peer-a')
})

test('installing with hoistPattern=*', async () => {
const prefix = f.prepare('simple-shamefully-flatten')
const reporter = jest.fn()
Expand Down