question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce peerDependencies

See original GitHub issue

Currently just about every package has 2 peerDependencies: request and auth. In my experience peerDependencies are hard for people to grok/manage. Ideally we’d have it so that all packages only have a single peer dependency, which would be request.

First, I don’t think any of these packages need to even declare a dependency (peer or otherwise) on arcgis-rest-auth (they never import from it):

  • arcgis-rest-feature-layer
  • arcgis-rest-geocoding
  • arcgis-rest-routing

We should remove those dependencies.

Second, arcgis-rest-service-admin only imports IUserRequestOptions from auth. We could move that interface to either the request or types package and drop the dependency on auth.

Side note, it looks like the types package is under dependencies of all the other packages, but it probably should be under devDependencies, right?

OK, finally, only the arcgis-rest-portal package actually imports a concrete implementation from auth, UserSession, but it only uses it type declarations (e.g. export function getUserUrl(session: UserSession): string). We can’t move the UserSession class to the types package. We could move the dependency under devDependencies, but it would be up to us to make sure we don’t introduce any runtime uses (like new UserSession()). Seems a bit risky. Maybe we just leave it as under peerDependencies in this case?

To me the only downside of moving away from having auth as a peerDependency is that we’ll have to rely on the docs (alone) to get across the message that “You need to install @esri/arcgis-rest-auth if you need to make authenticated requests.”

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
noahmulfingercommented, Sep 10, 2021

Just adding my two cents: Would it make more sense to rename APIKey to APIKeySession? That way it would be consistent with the other session objects, like UserSession and ApplicationSession.

1reaction
alaframboisecommented, Sep 9, 2021

I don’t really think import {APIKey} from “request” is super strange. There really isn’t anything else to name it since it isn’t really like the other *Session objects.

You don’t get an APIKey back from a declare.

I’m find with everything else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Addressing the shortcomings of peer dependencies - HackMD
Peer dependencies are intended to help reduce duplicate installs in applications by allowing libraries to opt out of introducing them, yet fall short...
Read more >
How to prevent peerDependency from being bundled #500
the peerDependencies are not installed by default. It just warns the requiring component that it needs that dependency to be installed by ...
Read more >
Automate peer dependency management - Katy DeCorah
Through strategic use of peer dependencies and dependabot, we've significantly reduced our dependency maintenance.
Read more >
Understanding Peer Dependencies in JavaScript
When to use peerDependencies? Peer dependencies really come into play when you're developing code that will be used by others, such as plugins ......
Read more >
Understanding Dev, Peer, and Regular Dependencies
peerDependencies are a crucial tool in reducing the size of your final production app. Let's take a look at why. Imagine that you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found