fix: downgrade npm-packlist to improve performance (#7301)

ref #6997
ref #7250
This commit is contained in:
Zoltan Kochan
2023-11-12 14:00:29 +02:00
committed by GitHub
parent fe1f0f7341
commit 74432d605e
7 changed files with 195 additions and 709 deletions

View File

@@ -0,0 +1,8 @@
---
"@pnpm/fs.packlist": patch
"pnpm": patch
---
Downgraded `npm-packlist` because the newer version significantly slows down the installation of local directory dependencies, making it unbearably slow.
`npm-packlist` was upgraded in [this PR](https://github.com/pnpm/pnpm/pull/7250) to fix [#6997](https://github.com/pnpm/pnpm/issues/6997). We added our own file deduplication to fix the issue of duplicate file entries.

View File

@@ -212,3 +212,8 @@ declare module '@pnpm/npm-conf/lib/types' {
const npmTypes: npmType
export = npmTypes
}
declare module 'npm-packlist' {
function npmPacklist (opts: { path: string }): Promise<string[]>
export = npmPacklist
}

View File

@@ -15,7 +15,7 @@ pnpm add @pnpm/fs.packlist
## Usage
```js
const { packlist } = require('path')
const { packlist } = require('@pnpm/fs.packlist')
const files = packlist('/package-dir')
```

View File

@@ -27,14 +27,11 @@
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/fs/packlist#readme",
"dependencies": {
"@npmcli/arborist": "npm:@pnpm/arborist__fork@7.2.1",
"npm-packlist": "^8.0.0"
"npm-packlist": "5.1.3"
},
"funding": "https://opencollective.com/pnpm",
"devDependencies": {
"@pnpm/fs.packlist": "workspace:*",
"@types/npm-packlist": "^7.0.2",
"@types/npmcli__arborist": "5.6.4"
"@pnpm/fs.packlist": "workspace:*"
},
"exports": {
".": "./lib/index.js"

View File

@@ -1,8 +1,11 @@
import Arborist from '@npmcli/arborist'
import npmPacklist from 'npm-packlist'
export async function packlist (pkgDir: string) {
const arborist = new Arborist(({ path: pkgDir }))
const tree = await arborist.loadActual()
return npmPacklist(tree)
export async function packlist (pkgDir: string): Promise<string[]> {
const files = await npmPacklist({ path: pkgDir })
// There's a bug in the npm-packlist version that we use,
// it sometimes returns duplicates.
// Related issue: https://github.com/pnpm/pnpm/issues/6997
// Unfortunately, we cannot upgrade the library
// newer versions of npm-packlist are very slow.
return Array.from(new Set(files.map((file) => file.replace(/^\.[/\\]/, ''))))
}

View File

@@ -183,6 +183,7 @@
"is-port-reachable",
"load-json-file",
"mem",
"npm-packlist",
"node-fetch",
"normalize-newline",
"p-any",

868
pnpm-lock.yaml generated
View File

File diff suppressed because it is too large Load Diff