Expand description
Platform filtering for os / cpu / libc package metadata.
npm-style packages can declare the platforms they support via the
os, cpu, and libc arrays in package.json. Each entry is
either a positive match ("linux", "x64", "glibc") or a
negation prefixed with ! ("!win32"). pnpm’s rule:
- empty array → unconstrained (installable everywhere)
- any negation hit → reject
- at least one pos → accept only if one positive matches
- negations only → accept if no negation matched
pnpm lets the user widen the match set beyond the host via
pnpm.supportedArchitectures — an object with os/cpu/libc
arrays, each entry either a concrete value or the literal "current"
which expands to the host triple. The package passes if ANY of the
(os, cpu, libc) combinations in the supported set is installable.
This module stays intentionally small: no reading of config, no
serde, just the matcher and host detection. Configuration lives on
the Resolver, which calls is_supported during filtering.
Structs§
- Supported
Architectures - User-declared override for the host triple used when filtering
optional dependencies. Missing arrays fall back to the host; the
literal
"current"inside any array expands to the same host value so users can write["current", "linux"]to keep their native platform and also resolve optionals for Linux.
Functions§
- filter_
graph - Remove optional dependencies that fail the platform check or appear in the
ignore list from a parsed
LockfileGraph, then garbage-collect any packages that become unreachable from the surviving importers. - host_
triple - Return the host’s (os, cpu, libc) triple using npm’s vocabulary.
libcis"glibc"/"musl"on Linux and""elsewhere — npm only setslibcon Linux packages, so non-Linux hosts treat libc constraints as a no-op. - is_
supported - Decide whether a package is installable on any of the (os, cpu,
libc) combinations expanded from
supported. Thepkg_libccheck is skipped when the host libc is empty (non-Linux) — npm doesn’t enforce libc off Linux. - mark_
optional_ packages - Set each package’s
optionalflag the way pnpm marks thesnapshots:section: a package isoptional: truewhen it is reachable only through optional dependency edges (the classic case is every@esbuild/*platform native sitting underesbuild’soptionalDependencies). pnpm derives this during resolution; aube recomputes it as a post-resolve pass so freshly resolved lockfiles carry the same markers pnpm writes instead of an empty{}snapshot. - mark_
transitive_ peer_ dependencies - Populate each package’s
transitive_peer_dependenciesthe way pnpm does: a snapshot lists every peer name that some package in its dependency subtree declares but leaves unresolved (the peers that “bubble up” to be provided by a consumer). A peer that was resolved is mirrored into the declaring package’sdependencies(pnpm and aube both do this — e.g.@babel/corelands in@babel/helper-module-transforms’s deps), sopeer_dependenciesminusdependenciesis exactly the unresolved set. Those unresolved names are propagated to every ancestor; a package never lists its own peers.