mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-11 09:28:24 -04:00
perf: fix a perf regression shipped in v5.13.7
Fixed a performance regression that was caused by #3032 and shipped in pnpm v5.13.7 The performance of repeat `pnpm install` execution was in some cases significantly slower. PR #3061
This commit is contained in:
5
.changeset/moody-moose-fix.md
Normal file
5
.changeset/moody-moose-fix.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
---
|
||||
|
||||
Fixed a performance regression that was caused by [#3032](https://github.com/pnpm/pnpm/pull/3032).
|
||||
@@ -223,11 +223,6 @@ 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])
|
||||
@@ -276,8 +271,15 @@ export default async (opts: HeadlessOptions) => {
|
||||
|
||||
let newHoistedDependencies!: HoistedDependencies
|
||||
if (opts.hoistPattern != null || opts.publicHoistPattern != null) {
|
||||
// It is important to keep the skipped packages in the lockfile which will be saved as the "current lockfile".
|
||||
// pnpm is comparing the current lockfile to the wanted one and they should much.
|
||||
// But for hoisting, we need a version of the lockfile w/o the skipped packages, so we're making a copy.
|
||||
const hoistLockfile = {
|
||||
...filteredLockfile,
|
||||
packages: R.omit(Array.from(skipped), filteredLockfile.packages),
|
||||
}
|
||||
newHoistedDependencies = await hoist({
|
||||
lockfile: filteredLockfile,
|
||||
lockfile: hoistLockfile,
|
||||
lockfileDir,
|
||||
privateHoistedModulesDir: hoistedModulesDir,
|
||||
privateHoistPattern: opts.hoistPattern ?? [],
|
||||
|
||||
@@ -502,7 +502,6 @@ test('should recreate node_modules with hoisting', async () => {
|
||||
|
||||
test('hoisting should not create a broken symlink to a skipped optional dependency', async () => {
|
||||
const project = prepareEmpty()
|
||||
console.log(process.cwd())
|
||||
|
||||
await install({
|
||||
optionalDependencies: {
|
||||
@@ -522,4 +521,9 @@ test('hoisting should not create a broken symlink to a skipped optional dependen
|
||||
}, await testDefaults({ publicHoistPattern: '*' }))
|
||||
|
||||
await project.hasNot('dep-of-optional-pkg')
|
||||
|
||||
const rootModules = assertProject(process.cwd())
|
||||
const currentLockfile = await rootModules.readCurrentLockfile()
|
||||
const wantedLockfile = await rootModules.readLockfile()
|
||||
expect(currentLockfile).toStrictEqual(wantedLockfile)
|
||||
})
|
||||
Reference in New Issue
Block a user