Repository navigation
Closed
pnpm/pnpm
#17415Description
Found by a defect-hotspot pass over the 90 days to 2026-10-26.
Property
For the same package directory, every pnpm path that selects a package's files returns the file and link set npm-packlist returns. Those paths are pack/publish, git and directory deps, patch-commit, deploy and the injected-copy writers.
Fixes in the loop
- Seed commits: fix(pack): honor .npmignore negations under excluded directories and extglobs pnpm#16761, fix(pack): preserve symlinks in pack and deploy outputs pnpm#15440.
- Fixes: fix(pack): ship only the always-included files when files is empty pnpm#16892, fix(fs-packlist): honor nested ignore files when
filesis set pnpm#16920, fix(fs-packlist): re-include the directories main, browser, and bin point into pnpm#16918, fix(fs-packlist): exclude npm-packlist's default ignore patterns from pack pnpm#16971, fix(fs-packlist): unify package selection rules pnpm#17135, fix(pack): expand numeric brace ranges pnpm#17146, fix(packlist): prevent escaping directory symlinks and path traversals in bundled dependencies pnpm#16619, fix: keep a package's links to its own files in synced injected copies pnpm#17088, fix(deploy): preserve links to deployed dependencies pnpm#17296, fix: sync only the package files into injected copies after scripts pnpm#17033. - Issues: pnpm 12.10 no longer honours those extglob negations pnpm#16743, pnpm 12 pack always includes any root file that starts with "readme" pnpm#16753, pnpm pack / publish with "files": [] includes every file pnpm#16889, pnpm 12
pack/publishignores a nested.npmignorewhenfilesis set (regression from pnpm 11, differs from npm) pnpm#16909, pnpm 12packkeeps only themain/binfile of a gitignored directory and ignoresbrowser(npm and pnpm 11 pack the whole directory) pnpm#16908, pnpm 12 packs junk files that npm and pnpm 11 exclude (.*.swp, ._*, build/config.gypi, .lock-wscript, .wafpickle-*, archived-packages/) pnpm#16955, deploy silently drops project symlinks to dependencies installed in its output pnpm#17288.
Almost every file-selection fix came from a user who compared the output with npm or pnpm 11.
Design flaw
- A hand port with a late oracle.
pnpm/crates/fs-packlistports ignore-walk, minimatch and npm-packlist by hand, while v11 wraps npm-packlist. The parity test arrived with fix(fs-packlist): unify package selection rules pnpm#17135, after about ten fixes. Its limits:- it uses one fixed file tree with few nested ignore files;
- it has no swap or AppleDouble files, no deep trees and no case variation;
- its oracle is the v11 wrapper, not
npm pack.
- Several deciders of the file and link set.
- v12 has its own symlink rules in each of:
packlist_with_sources, the git-fetcher re-export (used by the directory fetcher andpatching/src/commit.rs),walk_all_filesunderdeployAllFiles, theinjected-deps-syncerdir_patcher, and the deps-restorer importer'sSymlinkTargets. - v11 has the same spread across its packlist subclass,
directory-fetcher,indexed-pkg-importer,cafsandDirPatcher.
- v12 has its own symlink rules in each of:
- Known divergences live in code comments, not in a list the tests can check. Examples are the named-file depth rule from fix(fs-packlist): honor nested ignore files when
filesis set pnpm#16920 and exact-case entry points from fix(fs-packlist): re-include the directories main, browser, and bin point into pnpm#16918.
Proposed change (medium, mostly test-side)
- Generate the corpus. Use a grammar over paths (depth, dotfiles, case, swap and AppleDouble names, symlinks), ignore files at random depths, and
files/main/browser/binvalues from a glob grammar. Run each fixture through both packlists, and throughnpm pack --dry-run --jsonin a nightly job. - Keep the deliberate divergences as a named allowlist.
- Route every consumer through one API that returns the files plus the admitted links. Importers and syncers then apply only the placement policy.
Tests that would have caught the loop
generated_trees_match_npm_packlist: a proptest with shrinking, checked againstparity.mjs.pack_matches_npm_pack_dry_run: nightly, including a slice of real packages.every_file_selector_agrees_with_pack: the same fixture goes through pack, the git fetcher, the directory fetcher, deploy and the injected sync, with identical file and link sets asserted. This catches fix: sync only the package files into injected copies after scripts pnpm#17033, fix: keep a package's links to its own files in synced injected copies pnpm#17088 and fix(deploy): preserve links to deployed dependencies pnpm#17296.
Fixes the change would have made unnecessary
The generated differential would have caught every v12-versus-npm divergence fixed in pnpm/pnpm#16761, pnpm/pnpm#16892, pnpm/pnpm#16920, pnpm/pnpm#16918, pnpm/pnpm#16971 and pnpm/pnpm#17146. Escape-path symlink fuzzing would have caught pnpm/pnpm#16619.
Written by an agent (Claude Code, claude-opus-5-5).
Metadata
Metadata
Assignees
Labels
No labels
Activity
zkochan commentedon Oct 27, 2026
Opened pnpm/pnpm#17415 to implement this task:
SelectedPackageFiles,select_package_files,select_dir_package_files, andpacklist_dirinpnpm-fs-packlistreturning the selected files plus admitted internal symlinks (AdmittedSymlink).pnpm_fs::internal_symlink(SymlinkTargets,SymlinkTargetKind,AdmittedSymlink,SymlinkPlacementContext,SymlinkPlacement,admit_internal_symlink,resolve_symlink_placement,recreate_internal_symlink,selected_paths_and_ancestors,relative_link_target,symlink_file_or_copy) and routedpnpm-fs-packlist,pnpm-pack,pnpm-git-fetcher,pnpm-directory-fetcher,pnpm-patching(patch-commit),pnpm-deps-restorer(import_indexed_dir/deploy), andpnpm-injected-deps-syncer(syncInjectedDepsAfterScripts,DirPatcher,publish_edits) through it.DELIBERATE_DIVERGENCESwith dedicated witness tests (deliberate_divergences_have_witnesses).generated_trees_match_npm_packlist(proptestwith shrinking over path depth, dotfiles, case, swap/AppleDouble names, symlinks, nested.npmignore/.gitignore, andfiles/main/browser/binglob grammars) checkingpnpm-fs-packlistagainst bothnpm-packlistand@pnpm/fs.packlist.pack_matches_npm_pack_dry_runcomparingpnpm-fs-packlistagainstnpm pack --dry-run --json(including a corpus of real npm tarballs) and wired it into the nightlycargo-equivalence.ymlworkflow.every_file_selector_agrees_with_packinpnpm-cli, running the same fixture throughpack,GitFetcher,DirectoryFetcher,patch-commit,deploy, and the injected-dependency sync paths (import_indexed_dir,syncInjectedDepsAfterScripts,DirPatcher, andpublish_edits).generated_trees_match_npm_packlistcaught and shrunk a bug in@pnpm/fs.packlist(pnpm11/fs/packlist/src/index.ts) where an unnormalized manifest with a stringbinfield ("bin": "lib/index.js") was left as a string instead of converted to an object, causingnpm-packlist(for (const key in bin)) to iterate over character indices (0..n).every_file_selector_agrees_with_packcaught a bug inpnpm-deps-restorer(import_indexed_dir) where importing an internal symlink to an unselected file as a regular file (SymlinkPlacement::ImportFile) underPackageImportMethod::Auto/Hardlinkpassed the symlink path tofs::hard_link, creating a hardlink to the symlink inode (a broken symlink innode_modules) instead of hardlinking the canonical target file.Generated by Antigravity (Claude Opus 4.6)
fix(packlist): unify package file selection and test against npm-pack…
fix(packlist): unify package file selection and test against npm-pack…
fix(packlist): unify package file selection and test against npm-pack…