mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-11 17:42:43 -04:00
5
.changeset/hungry-dolls-rush.md
Normal file
5
.changeset/hungry-dolls-rush.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
---
|
||||
|
||||
Don't create broken symlinks to skipped optional dependencies, when hoisting.
|
||||
@@ -223,6 +223,11 @@ export default async (opts: HeadlessOptions) => {
|
||||
pnpmVersion: opts.currentEngine.pnpmVersion,
|
||||
} as LockfileToDepGraphOptions
|
||||
)
|
||||
if (filteredLockfile.packages) {
|
||||
for (const skippedDepPath of Array.from(skipped)) {
|
||||
delete filteredLockfile.packages[skippedDepPath]
|
||||
}
|
||||
}
|
||||
if (opts.enablePnp) {
|
||||
const importerNames = R.fromPairs(
|
||||
opts.projects.map(({ manifest, id }) => [id, manifest.name ?? id])
|
||||
|
||||
@@ -499,3 +499,27 @@ test('should recreate node_modules with hoisting', async () => {
|
||||
expect(Object.keys(modulesManifest?.hoistedDependencies ?? {}).length > 0).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
test('hoisting should not create a broken symlink to a skipped optional dependency', async () => {
|
||||
const project = prepareEmpty()
|
||||
console.log(process.cwd())
|
||||
|
||||
await install({
|
||||
optionalDependencies: {
|
||||
'not-compatible-with-any-os': '*',
|
||||
},
|
||||
}, await testDefaults({ publicHoistPattern: '*' }))
|
||||
|
||||
await project.hasNot('dep-of-optional-pkg')
|
||||
|
||||
// Verifying the same with headless installation
|
||||
await rimraf('node_modules')
|
||||
|
||||
await install({
|
||||
optionalDependencies: {
|
||||
'not-compatible-with-any-os': '*',
|
||||
},
|
||||
}, await testDefaults({ publicHoistPattern: '*' }))
|
||||
|
||||
await project.hasNot('dep-of-optional-pkg')
|
||||
})
|
||||
Reference in New Issue
Block a user