npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.52k stars 3.19k forks source link

[FEATURE] True mirror registry #7912

Closed hyrious closed 4 days ago

hyrious commented 1 week ago

Background

Currently the registry config affects the lockfile and fetch cache key, which affects anyone (including the CI, like github actions) working on the same project using the same registry to fetch dependencies. This behavior is correct, but seems beyond the mirror registry's purpose.

Here I want to distinguish a thing: There're 2 kinds of registries.

I know there's a config replace-registry-host=always which can always respect the registry setting from command line. But that seems a footgun and can't be treat as a default behavior.

Proposal

Therefore, I'm proposing a feature to separate the mirror usage out. For example mirror-registry=<url> or registry-is-mirror=true. When it is set, the arborist uses this config to fetch dependencies like what it currently does. But it writes out the default registry (https://registry.npmjs.org/) in the package-lock.json's resolved field.

Alternative

pnpm and deno, only write out a sha512 integrity in the lockfile. Maybe we can implement a package-lock.json v4 starting from here?

wraithgar commented 4 days ago

This would be a much larger discussion that would need to start in the rfcs repo https://github.com/npm/rfcs