Skip to content

feat: excludeLinksFromLockfile#6570

Merged
zkochan merged 3 commits into
mainfrom
exclude-links-from-lockfile
May 21, 2023
Merged

feat: excludeLinksFromLockfile#6570
zkochan merged 3 commits into
mainfrom
exclude-links-from-lockfile

Conversation

@zkochan
Copy link
Copy Markdown
Member

@zkochan zkochan commented May 21, 2023

No description provided.

@zkochan zkochan requested a review from a team May 21, 2023 00:55
@zkochan zkochan merged commit 301b8e2 into main May 21, 2023
@zkochan zkochan deleted the exclude-links-from-lockfile branch May 21, 2023 09:23
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants