@pnpm/fs.packlist 1100.0.0 → 1100.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/README.md +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +86 -9
- package/package.json +8 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @pnpm/fs.packlist
|
|
2
|
+
|
|
3
|
+
## 1100.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `pnpm pack` now respects workspace-root `.npmignore` and `.gitignore` files when packing workspace packages.
|
|
8
|
+
|
|
9
|
+
## 1100.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- dd8d5d7: Fix `pnpm pack` not bundling dependencies listed in `bundleDependencies` (or `bundledDependencies`). The npm-packlist upgrade in pnpm 11 changed its API to require the caller to pre-populate the dependency tree, which the wrapper was not doing — `bundleDependencies` were silently dropped from the tarball [#11519](https://github.com/pnpm/pnpm/issues/11519).
|
|
14
|
+
|
|
15
|
+
## 1001.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- 491a84f: This package is now pure ESM.
|
|
20
|
+
- 7d2fd48: Node.js v18, 19, 20, and 21 support discontinued.
|
|
21
|
+
|
|
22
|
+
## 2.0.0
|
|
23
|
+
|
|
24
|
+
### Major Changes
|
|
25
|
+
|
|
26
|
+
- 43cdd87: Node.js v16 support dropped. Use at least Node.js v18.12.
|
|
27
|
+
|
|
28
|
+
## 1.0.3
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 9fb45d0fc: `pnpm publish` should pack "main" file or "bin" files defined in "publishConfig" [#4195](https://github.com/pnpm/pnpm/issues/4195).
|
|
33
|
+
|
|
34
|
+
## 1.0.2
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- 74432d605: Downgraded `npm-packlist` because the newer version significantly slows down the installation of local directory dependencies, making it unbearably slow.
|
|
39
|
+
|
|
40
|
+
`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.
|
|
41
|
+
|
|
42
|
+
## 1.0.1
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- c7f1359b6: After upgrading one of our dependencies, we started to sometimes have an error on publish. We have forked `@npmcli/arborist` to patch it with a fix [#7269](https://github.com/pnpm/pnpm/pull/7269).
|
|
47
|
+
|
|
48
|
+
## 1.0.0
|
|
49
|
+
|
|
50
|
+
### Major Changes
|
|
51
|
+
|
|
52
|
+
- 500363647: Initial release.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Get a list of the files to add from a directory into an npm package
|
|
4
4
|
|
|
5
5
|
<!--@shields('npm')-->
|
|
6
|
-
[](https://
|
|
6
|
+
[](https://npmx.dev/package/@pnpm/fs.packlist)
|
|
7
7
|
<!--/@-->
|
|
8
8
|
|
|
9
9
|
## Installation
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,21 +1,98 @@
|
|
|
1
|
-
import fs from 'node:fs
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import util from 'node:util';
|
|
4
|
+
import { isSubdir } from 'is-subdir';
|
|
4
5
|
import npmPacklist from 'npm-packlist';
|
|
5
6
|
export async function packlist(pkgDir, opts) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const resolvedPkgDir = path.resolve(pkgDir);
|
|
8
|
+
const workspaceDir = opts?.workspaceDir == null ? undefined : path.resolve(opts.workspaceDir);
|
|
9
|
+
const pkg = opts?.manifest ?? readPackageJson(resolvedPkgDir);
|
|
10
|
+
const tree = buildRootTree(resolvedPkgDir, pkg);
|
|
11
|
+
const packlistOpts = workspaceDir != null && workspaceDir !== resolvedPkgDir && isSubdir(workspaceDir, resolvedPkgDir)
|
|
12
|
+
? { prefix: workspaceDir, workspaces: [resolvedPkgDir] }
|
|
13
|
+
: undefined;
|
|
14
|
+
const files = await npmPacklist(tree, packlistOpts);
|
|
15
|
+
return files.map((file) => file.replace(/^\.[/\\]/, ''));
|
|
16
|
+
}
|
|
17
|
+
function buildRootTree(pkgDir, pkg) {
|
|
18
|
+
const bundledDeps = getRootBundledDeps(pkg);
|
|
19
|
+
// npm-packlist's gatherBundles() iterates package.bundleDependencies directly,
|
|
20
|
+
// so the field must be an array. Normalize true/undefined to an explicit list.
|
|
21
|
+
const normalizedPkg = normalizePackage(pkg);
|
|
22
|
+
normalizedPkg.bundleDependencies = bundledDeps;
|
|
23
|
+
delete normalizedPkg.bundledDependencies;
|
|
24
|
+
const root = makeNode(pkgDir, normalizedPkg, true);
|
|
25
|
+
const seen = new Map([[pkgDir, root]]);
|
|
26
|
+
populateEdges(root, bundledDeps, seen);
|
|
27
|
+
return root;
|
|
28
|
+
}
|
|
29
|
+
function buildBundledTree(pkgDir, seen) {
|
|
30
|
+
const cached = seen.get(pkgDir);
|
|
31
|
+
if (cached)
|
|
32
|
+
return cached;
|
|
33
|
+
const pkg = readPackageJson(pkgDir);
|
|
34
|
+
const node = makeNode(pkgDir, normalizePackage(pkg), false);
|
|
35
|
+
seen.set(pkgDir, node);
|
|
36
|
+
populateEdges(node, getNestedBundledDeps(pkg), seen);
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
function populateEdges(node, deps, seen) {
|
|
40
|
+
for (const dep of deps) {
|
|
41
|
+
const depDir = resolveDependency(dep, node.path);
|
|
42
|
+
if (!depDir)
|
|
43
|
+
continue;
|
|
44
|
+
const depNode = buildBundledTree(depDir, seen);
|
|
45
|
+
node.edgesOut.set(dep, { to: depNode, peer: false, dev: false });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function makeNode(pkgDir, pkg, isProjectRoot) {
|
|
49
|
+
const node = {
|
|
8
50
|
path: pkgDir,
|
|
9
|
-
package:
|
|
10
|
-
isProjectRoot
|
|
51
|
+
package: pkg,
|
|
52
|
+
isProjectRoot,
|
|
53
|
+
isLink: false,
|
|
11
54
|
edgesOut: new Map(),
|
|
12
55
|
};
|
|
13
|
-
|
|
14
|
-
return
|
|
56
|
+
node.target = node;
|
|
57
|
+
return node;
|
|
58
|
+
}
|
|
59
|
+
function getRootBundledDeps(pkg) {
|
|
60
|
+
const bundle = pkg.bundleDependencies ?? pkg.bundledDependencies;
|
|
61
|
+
if (Array.isArray(bundle))
|
|
62
|
+
return bundle;
|
|
63
|
+
if (bundle === true) {
|
|
64
|
+
return Object.keys((pkg.dependencies ?? {}));
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
function getNestedBundledDeps(pkg) {
|
|
69
|
+
const dependencies = (pkg.dependencies ?? {});
|
|
70
|
+
const optionalDependencies = (pkg.optionalDependencies ?? {});
|
|
71
|
+
return [...Object.keys(dependencies), ...Object.keys(optionalDependencies)];
|
|
72
|
+
}
|
|
73
|
+
function resolveDependency(depName, fromDir) {
|
|
74
|
+
let currentDir = fromDir;
|
|
75
|
+
while (true) {
|
|
76
|
+
const candidate = path.join(currentDir, 'node_modules', depName);
|
|
77
|
+
try {
|
|
78
|
+
const stat = fs.statSync(path.join(candidate, 'package.json'));
|
|
79
|
+
if (stat.isFile())
|
|
80
|
+
return candidate;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (!util.types.isNativeError(err) || !('code' in err) || err.code !== 'ENOENT') {
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const parent = path.dirname(currentDir);
|
|
88
|
+
if (parent === currentDir)
|
|
89
|
+
return undefined;
|
|
90
|
+
currentDir = parent;
|
|
91
|
+
}
|
|
15
92
|
}
|
|
16
|
-
|
|
93
|
+
function readPackageJson(dir) {
|
|
17
94
|
try {
|
|
18
|
-
return JSON.parse(
|
|
95
|
+
return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
19
96
|
}
|
|
20
97
|
catch (err) {
|
|
21
98
|
if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fs.packlist",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.2",
|
|
4
4
|
"description": "Get a list of the files to add from a directory into an npm package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"funding": "https://opencollective.com/pnpm",
|
|
11
|
-
"repository":
|
|
12
|
-
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/fs/packlist"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/fs/packlist#readme",
|
|
13
16
|
"bugs": {
|
|
14
17
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
15
18
|
},
|
|
@@ -24,10 +27,11 @@
|
|
|
24
27
|
"!*.map"
|
|
25
28
|
],
|
|
26
29
|
"dependencies": {
|
|
30
|
+
"is-subdir": "^2.0.0",
|
|
27
31
|
"npm-packlist": "10.0.4"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
|
-
"@pnpm/fs.packlist": "1100.0.
|
|
34
|
+
"@pnpm/fs.packlist": "1100.0.2"
|
|
31
35
|
},
|
|
32
36
|
"engines": {
|
|
33
37
|
"node": ">=22.13"
|