preactjs / wmr

👩‍🚀 The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.93k stars 110 forks source link

Make npm registry url configurable #167

Open marvinhagemeister opened 3 years ago

marvinhagemeister commented 3 years ago

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.

developit commented 3 years ago

@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.

pajaydev commented 3 years ago

@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 ?.

developit commented 3 years ago

@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.

chrstntdd commented 3 years ago

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?