wmr icon indicating copy to clipboard operation
wmr copied to clipboard

Make npm registry url configurable

Open marvinhagemeister opened this issue 5 years ago • 4 comments

Just came across one of our client projects, which uses their own npm registry instead of the official one. By making it configurable via cli-flag like --registry https://my-registry.com we could support that use case.

I'm wondering if this is how we can make our npm plugin testable too! We could spin up a fake registry since we only ever download the tarball and use the --registry flag in our tests to point to our mocked server.

marvinhagemeister avatar Oct 20 '20 11:10 marvinhagemeister

@marvinhagemeister I wonder if we could check for an npmrc file at $cwd/.npmrc and pull the registry from there? Maybe in addition to the flag or something. Or we could even allow setting "registry":"..." in the package.json... so many options.

developit avatar Oct 20 '20 15:10 developit

@marvinhagemeister @developit I would love to do this change, I can see three idea's

  1. getting it from cli-flag.
  2. keeping .npmrc file and reading from it.
  3. Making an entry in package.json.

Shall we support all three ideas ?.

pajaydev avatar Dec 02 '20 21:12 pajaydev

@pajaydev I'm not sure about a CLI flag, since folks would need to pass it everywhere they run WMR.

I actually am thinking maybe as a start we could just check for process.env.NPM_CONFIG_REGISTRY? It's only defined when the script is run from npm, but that's most cases.

developit avatar Dec 03 '20 21:12 developit

Hey folks! I'm running into this same issue and would be interesting in getting this into wmr. Has there been any more progress on https://github.com/preactjs/wmr/issues/151 that is blocking this from being implemented now?

Also, specific to my use case is that this project lives as a workspace within a mono-repo. This particular module being requested is present on disk and I have a hunch that it might be easier to resolve in the fs in these cases. Maybe mono-repo support is a whole separate discussion?

chrstntdd avatar Jan 18 '21 20:01 chrstntdd