fix: check the existense of a dep at the right dir

fixes a performance regression caused by #2531
This commit is contained in:
Zoltan Kochan
2020-05-06 02:57:04 +03:00
parent 7ca9702dc5
commit 0730bb9381
4 changed files with 10 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/resolve-dependencies": patch
---
Check the existense of a dependency in `node_modules` at the right location.

View File

@@ -34,6 +34,7 @@
"@pnpm/npm-resolver": "workspace:8.0.0-alpha.1",
"@pnpm/package-is-installable": "workspace:4.0.7",
"@pnpm/pick-registry-for-package": "workspace:1.0.0",
"@pnpm/pkgid-to-filename": "^3.0.0-0",
"@pnpm/resolver-base": "workspace:7.0.0",
"@pnpm/store-controller-types": "workspace:8.0.0-alpha.2",
"@pnpm/types": "workspace:5.0.0",

View File

@@ -17,6 +17,7 @@ import {
import logger from '@pnpm/logger'
import packageIsInstallable from '@pnpm/package-is-installable'
import pickRegistryForPackage from '@pnpm/pick-registry-for-package'
import pkgIdToFilename from '@pnpm/pkgid-to-filename'
import {
DirectoryResolution,
PreferredVersions,
@@ -503,7 +504,7 @@ async function resolveDependency (
// we can safely assume that it doesn't exist in `node_modules`
currentLockfileContainsTheDep &&
options.relDepPath && options.dependencyLockfile &&
await exists(path.join(ctx.virtualStoreDir, `${options.depPath}/node_modules/${nameVerFromPkgSnapshot(options.relDepPath, options.dependencyLockfile).name}/package.json`)) &&
await exists(path.join(ctx.virtualStoreDir, `${pkgIdToFilename(options.depPath, ctx.prefix)}/node_modules/${nameVerFromPkgSnapshot(options.relDepPath, options.dependencyLockfile).name}/package.json`)) &&
(options.currentDepth > 0 || wantedDependency.alias && await exists(path.join(ctx.modulesDir, wantedDependency.alias))))
if (!proceed && depIsLinked) {

2
pnpm-lock.yaml generated
View File

@@ -2385,6 +2385,7 @@ importers:
'@pnpm/npm-resolver': 'link:../npm-resolver'
'@pnpm/package-is-installable': 'link:../package-is-installable'
'@pnpm/pick-registry-for-package': 'link:../pick-registry-for-package'
'@pnpm/pkgid-to-filename': 3.0.0-0
'@pnpm/resolver-base': 'link:../resolver-base'
'@pnpm/store-controller-types': 'link:../store-controller-types'
'@pnpm/types': 'link:../types'
@@ -2407,6 +2408,7 @@ importers:
'@pnpm/npm-resolver': 'workspace:8.0.0-alpha.1'
'@pnpm/package-is-installable': 'workspace:4.0.7'
'@pnpm/pick-registry-for-package': 'workspace:1.0.0'
'@pnpm/pkgid-to-filename': ^3.0.0-0
'@pnpm/resolve-dependencies': 'link:'
'@pnpm/resolver-base': 'workspace:7.0.0'
'@pnpm/store-controller-types': 'workspace:8.0.0-alpha.2'