Files
pnpm/pnpm11/resolving/default-resolver/tsconfig.json
Zoltan Kochan 91d3c2e220 refactor(registries): give the known-registry set one owner (#13591)
The built-in aliases and the user's `namedRegistries` were combined
independently at each place that needed them: `resolveNamedRegistries` in
constants, a second call inside the same verifier factory to build the URL
prefix list, and in pacquet a hand-rolled `chain` next to a separate
`build_named_registry_prefixes`. The Rust pair had already drifted — the
hand-rolled merge skipped the URL validation the other applied.

That set feeds two different consumers: alias lookup for an entry that names
its registry in the dep path, and the tarball-URL prefix list that decides
which registry an entry carrying only a recorded URL is verified against.
Splitting the merge across call sites is what made adding the `npmjs`
built-in look local while it silently redirected verification traffic for
lockfiles that record a registry.npmjs.org URL and name no alias at all.
That consequence was caught by an unrelated normalization test that happened
to use such a URL, not by anything at the edit site.

`KnownRegistries` now owns the merge and exposes both views, so a change to
either input reaches both consumers or neither. `createKnownRegistries`
computes the prefixes lazily because alias lookup runs per package while
prefix matching runs only for entries with a recorded URL.

Both stacks now pin the default prefix list in a test, so a new built-in
cannot land without stating where it sends verification traffic.

Writing that test surfaced a latent bug: the two built-in URLs are both 27
characters, and sorting by length alone left their relative order to hash-map
iteration, which varies between runs. The sort now tie-breaks
lexicographically in both stacks. No routing outcome changes — two prefixes
of equal length cannot both match one URL unless they are identical — but the
list is now stable enough to assert on.

Closes https://github.com/pnpm/pnpm/issues/13590
2026-08-02 19:40:34 +02:00

71 lines
1.2 KiB
JSON

{
"extends": "@pnpm/tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../__typings__/**/*.d.ts"
],
"references": [
{
"path": "../../config/normalize-registries"
},
{
"path": "../../core/error"
},
{
"path": "../../core/types"
},
{
"path": "../../engine/runtime/bun-resolver"
},
{
"path": "../../engine/runtime/deno-resolver"
},
{
"path": "../../engine/runtime/node-resolver"
},
{
"path": "../../fetching/fetcher-base"
},
{
"path": "../../fetching/tarball-fetcher"
},
{
"path": "../../fetching/types"
},
{
"path": "../../hooks/types"
},
{
"path": "../../network/auth-header"
},
{
"path": "../../network/fetch"
},
{
"path": "../../store/cafs-types"
},
{
"path": "../../testing/mock-agent"
},
{
"path": "../git-resolver"
},
{
"path": "../local-resolver"
},
{
"path": "../npm-resolver"
},
{
"path": "../resolver-base"
},
{
"path": "../tarball-resolver"
}
]
}