feat: excludeLinksFromLockfile#6570
Merged
Merged
Conversation
lvqq
approved these changes
May 21, 2023
6 tasks
zkochan
added a commit
that referenced
this pull request
May 28, 2026
Mirror pnpm's `excludeLinksFromLockfile` setting: * `pacquet-config`: add `exclude_links_from_lockfile` (default `false`) with env-overlay and `pnpm-workspace.yaml` wiring. * `pacquet-package-manager`: thread the flag through `install_with_fresh_lockfile` into the lockfile renderer. A `link:` direct dep is omitted from the importer's snapshot unless its manifest specifier starts with `workspace:`. * `pacquet-resolving-deps-resolver`: port the peer-resolution arm of the feature — `resolve_peers` now seeds `ParentRefs` for external `link:` direct deps with a node id rewritten to `link:<rel-from-lockfile_dir-to-modules_dir>/<alias>` when the link target is outside the lockfile root, mirroring upstream's `index.ts:232-244` `target` rewrite plus the `peerNodeIdToPeerId` link arm. The snapshot child edge falls back to the link node id verbatim when `pathsByNodeId` misses, matching upstream's `pathsByNodeId.get(childNodeId) ?? childNodeId` arm in `resolveChildren`. * `pacquet-deps-path`: port `linkPathToPeerVersion`. * `pacquet-fs`: extract `is_subdir` from `pacquet-cmd-shim` so the resolver and the cmd-shim share one implementation. Ports #6570, refs #12009.
zkochan
added a commit
that referenced
this pull request
May 28, 2026
Mirror pnpm's `excludeLinksFromLockfile` setting: * `pacquet-config`: add `exclude_links_from_lockfile` (default `false`) with env-overlay and `pnpm-workspace.yaml` wiring. * `pacquet-package-manager`: thread the flag through `install_with_fresh_lockfile` into the lockfile renderer. A `link:` direct dep is omitted from the importer's snapshot unless its manifest specifier starts with `workspace:`. * `pacquet-resolving-deps-resolver`: port the peer-resolution arm of the feature — `resolve_peers` now seeds `ParentRefs` for external `link:` direct deps with a node id rewritten to `link:<rel-from-lockfile_dir-to-modules_dir>/<alias>` when the link target is outside the lockfile root, mirroring upstream's `index.ts:232-244` `target` rewrite plus the `peerNodeIdToPeerId` link arm. The snapshot child edge falls back to the link node id verbatim when `pathsByNodeId` misses, matching upstream's `pathsByNodeId.get(childNodeId) ?? childNodeId` arm in `resolveChildren`. * `pacquet-deps-path`: port `linkPathToPeerVersion`. * `pacquet-fs`: extract `is_subdir` from `pacquet-cmd-shim` so the resolver and the cmd-shim share one implementation. Ports #6570, refs #12009.
zkochan
added a commit
that referenced
this pull request
May 28, 2026
Port the `excludeLinksFromLockfile` setting to pacquet so its behavior matches the TypeScript pnpm CLI (which has had this setting since [#6570](#6570)). Refs [#12009](#12009). When `excludeLinksFromLockfile: true` is set, pacquet now: - Omits bare `link:` direct dependencies from each importer's `pnpm-lock.yaml` entry (keeping `workspace:`-resolved links recorded). - Remaps external link targets to a stable `link:<rel-from-lockfile_dir-to-modules_dir>/<alias>` node id when seeding peer-resolution parents, so peer suffixes for snapshots that depend on a linked package don't carry the absolute path of the external link. The remap fires only when the link target is *outside* the lockfile root (per upstream's `isSubdir` gate). - Round-trips the setting into the lockfile's top-level `settings:` block so `getOutdatedLockfileSetting` can spot drift on the next install. ## Where it's hooked (mirrors pnpm) - **Config flag**: `pacquet-config` adds `exclude_links_from_lockfile: bool` (default `false`) — mirrors [`config/reader/src/Config.ts:71`](https://github.com/pnpm/pnpm/blob/094aa6e57b/config/reader/src/Config.ts#L71) and the [`false` default](https://github.com/pnpm/pnpm/blob/094aa6e57b/config/reader/src/index.ts#L144). - **Importer entry**: `dependencies_graph_to_lockfile::build_importer` mirrors upstream's [`addDirectDependenciesToLockfile` exclude-link gate](https://github.com/pnpm/pnpm/blob/094aa6e57b/installing/deps-resolver/src/index.ts#L449-L456) — drops `link:` direct deps from the importer entry unless their manifest specifier starts with `workspace:`. - **Peer-resolution remap**: `resolve_peers::build_importer_parents` ports the [`target` rewrite at `index.ts:232-244`](https://github.com/pnpm/pnpm/blob/094aa6e57b/installing/deps-resolver/src/index.ts#L232-L244). External `link:` parents are seeded into `ParentRefs` with a remapped node id (`link:<rel-from-lockfile_dir-to-modules_dir>/<alias>`), so the peer suffix stays stable across machines. - **Peer-id translation**: `build_peer_id` special-cases `link:` node ids and emits `PeerId::Pair { name: peer_alias, version: link_path_to_peer_version(rel) }` — the exact port of upstream's [`peerNodeIdToPeerId` link arm](https://github.com/pnpm/pnpm/blob/094aa6e57b/installing/deps-resolver/src/resolvePeers.ts#L984-L989). - **Snapshot child fallback**: a peer-resolved child whose node id is `link:<rel>` and isn't in `node_dep_paths` uses the link node id verbatim as the snapshot child ref — mirrors upstream's [`pathsByNodeId.get(childNodeId) ?? (childNodeId as DepPath)`](https://github.com/pnpm/pnpm/blob/094aa6e57b/installing/deps-resolver/src/resolvePeers.ts#L164) in `resolveChildren`. ## New shared helpers - `pacquet-deps-path::link_path_to_peer_version` — faithful port of upstream's [`linkPathToPeerVersion.ts`](https://github.com/pnpm/pnpm/blob/094aa6e57b/installing/deps-resolver/src/linkPathToPeerVersion.ts). Iterates Unicode scalars (not raw bytes), so multi-byte UTF-8 path segments round-trip intact; pinned by a `non_ascii_path_segments_round_trip` test covering Latin-1, CJK, and a non-BMP emoji. - `pacquet-fs::is_subdir` — promoted from a private `pacquet-cmd-shim` helper so the resolver and the cmd-shim share one implementation. Mirrors npm's [`is-subdir`](https://github.com/zkochan/packages/blob/main/is-subdir/index.js).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.