mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -04:00
6
.changeset/three-apricots-wonder.md
Normal file
6
.changeset/three-apricots-wonder.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/deps.graph-builder": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fixed a performance regression on running installation on a project with an up to date lockfile [#7297](https://github.com/pnpm/pnpm/issues/7297).
|
||||
4
deps/graph-builder/src/lockfileToDepGraph.ts
vendored
4
deps/graph-builder/src/lockfileToDepGraph.ts
vendored
@@ -134,8 +134,8 @@ export async function lockfileToDepGraph (
|
||||
currentPackages[depPath] && equals(currentPackages[depPath].dependencies, lockfile.packages![depPath].dependencies)
|
||||
let dirExists: boolean | undefined
|
||||
if (
|
||||
depIsPresent && isEmpty(currentPackages[depPath].optionalDependencies) &&
|
||||
isEmpty(lockfile.packages![depPath].optionalDependencies)
|
||||
depIsPresent && isEmpty(currentPackages[depPath].optionalDependencies ?? {}) &&
|
||||
isEmpty(lockfile.packages![depPath].optionalDependencies ?? {})
|
||||
) {
|
||||
dirExists = await pathExists(dir)
|
||||
if (dirExists) {
|
||||
|
||||
@@ -342,8 +342,8 @@ async function linkNewPackages (
|
||||
for (const depPath of wantedRelDepPaths) {
|
||||
if (currentLockfile.packages[depPath] &&
|
||||
(!equals(currentLockfile.packages[depPath].dependencies, wantedLockfile.packages[depPath].dependencies) ||
|
||||
!isEmpty(currentLockfile.packages[depPath].optionalDependencies) ||
|
||||
!isEmpty(wantedLockfile.packages[depPath].optionalDependencies))
|
||||
!isEmpty(currentLockfile.packages[depPath].optionalDependencies ?? {}) ||
|
||||
!isEmpty(wantedLockfile.packages[depPath].optionalDependencies ?? {}))
|
||||
) {
|
||||
// TODO: come up with a test that triggers the usecase of depGraph[depPath] undefined
|
||||
// see related issue: https://github.com/pnpm/pnpm/issues/870
|
||||
|
||||
@@ -145,6 +145,19 @@ test('no dependencies (lodash)', async () => {
|
||||
expect(typeof m.clone).toBe('function')
|
||||
})
|
||||
|
||||
test('only the new packages are added', async () => {
|
||||
prepareEmpty()
|
||||
const manifest = await addDependenciesToPackage({}, ['@pnpm/x'], await testDefaults())
|
||||
const reporter = sinon.spy()
|
||||
await addDependenciesToPackage(manifest, ['@pnpm/y'], await testDefaults({ reporter }))
|
||||
|
||||
expect(reporter.calledWithMatch({
|
||||
added: 1,
|
||||
level: 'debug',
|
||||
name: 'pnpm:stats',
|
||||
} as StatsLog)).toBeTruthy()
|
||||
})
|
||||
|
||||
test('scoped modules without version spec', async () => {
|
||||
const project = prepareEmpty()
|
||||
await addDependenciesToPackage({}, ['@zkochan/foo'], await testDefaults())
|
||||
|
||||
@@ -76,6 +76,20 @@ test('installing a simple project', async () => {
|
||||
requester: prefix,
|
||||
status: 'resolved',
|
||||
})).toBeTruthy()
|
||||
|
||||
reporter.resetHistory()
|
||||
await headlessInstall(await testDefaults({
|
||||
lockfileDir: prefix,
|
||||
reporter,
|
||||
}))
|
||||
// On repeat install no new packages should be added
|
||||
// covers https://github.com/pnpm/pnpm/issues/7297
|
||||
expect(reporter.calledWithMatch({
|
||||
added: 0,
|
||||
level: 'debug',
|
||||
name: 'pnpm:stats',
|
||||
prefix,
|
||||
} as StatsLog)).toBeTruthy()
|
||||
})
|
||||
|
||||
test('installing only prod deps', async () => {
|
||||
|
||||
Reference in New Issue
Block a user