cli icon indicating copy to clipboard operation
cli copied to clipboard

Make portal-client dependency optional

Open matejchalk opened this issue 1 year ago • 2 comments

User story

In order to streamline approval process in enterprises which vet every NPM package, it helps if the Code PushUp CLI has as few external dependencies as possible.

The @code-pushup/portal-client (which also pulls in graphql, graphql-request and graphql-tag) is only needed for uploading to portal. That means its installation could be optional.

Acceptance criteria

  • [ ] change @code-pushup/portal-client imports from static to dynamic
  • [ ] move @code-pushup/portal-client from dependencies to optionalDependencies
  • [ ] add additional portal setup instructions to documentation

matejchalk avatar Feb 06 '24 16:02 matejchalk

I want to confirm my understanding of how optionalDependencies would work here. When a user installs our package, npm will still attempt to install @code-pushup/portal-client even if it's marked as optional. If the installation fails (e.g., due to network problems), the main package would still install successfully.

My concern is that, under normal circumstances, it's unlikely for the installation to actually fail, meaning @code-pushup/portal-client would still get installed in most cases. Given that, does making it optional actually help reduce the number of dependencies for enterprise approval, or am I missing something about how optionalDependencies work?

hanna-skryl avatar Oct 09 '24 21:10 hanna-skryl

Good point about optional dependencies being installed by default, I hadn't considered that. But I think it's for the best actually 🤔

It's not that we think the installation could fail. It's about having a convenient way for the user to opt out of installing @code-pushup/portal-client if they're not using the portal, which they can't really do if it's a regular dependency. (This is actually something @BioPhoton was pushing for, I just wrote the issue, BTW. He was concerned that for enterprises who want to try out Code PushUp without paying for the portal, these dependencies could present an extra hurdle.)

Originally, I thought this means that portal users would have an extra setup step to get the portal running, but this way it's actually better. By default @code-pushup/portal-client will be installed, so no extra setup needed for portal users. But if some enterprise really cares about every dev dependency and they want to try out Code PushUp without paying for it, then we can instruct them to use --omit=dev --omit=optional (default is --omit=dev according to npm docs) when installing @code-pushup/cli. This way, most users (incl. paying customers) will have a simpler setup, but these "picky" enterprises can also be satisfied with an alternative setup. That's a good balance, IMHO 😁

matejchalk avatar Oct 10 '24 10:10 matejchalk