New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce peerDependencies #786
Comments
FYI - the above proposal is, an alternative, and I think a better one, to the idea we discussed in a call today of merging auth into request and drop the auth package. The downside of consolidation is that auth (14.9kb minified)is actually bigger than request (13.6kb minified) and it'd be a shame to more than double the size for anyone that truly doesn't need auth. |
I think we put this there so the types are always there for Typescript users. It doesn't have any impact on final bundle sizes though.
I wonder how much of that could be reduced by switching to ES2017 as a compile target in #785. In any event tree shaking would take care of it if you didn't use auth. The main benefit of separate modules is that if you DID screw up tree shaking it wouldn't bloat too much but I don't think this is too bad. |
I was thinking that TS consumers of the library would have everything they need the |
@tomwayson 2 updates to this:
|
I think we should still do this and get it into the 4.0 release. I will put up a PR. My motivation has less to do w/ bundle size than ease of maintenance, not just for this monorepo itself, but Hub.js and any similar libraries built on the rest-js libraries. I think |
@tomwayson you might want to wait for my build system PR 😄 it needs to touch every source file and test. |
@tomwayson I'm fine with merging |
OK, thx for the heads up on the build system PR. FYI re: bundle sizes, my idea is that after #785 and #788 are done that we'd drop the UMD build altogether. Though maybe the reason you're citing those above is that they are the easiest way to get the relative output sizes of the packages. re: merging request and auth, I'll take a look at that. |
I still think the UMD build is a good idea for now since it allows you to use ArcGIS REST JS with the JS API as AMD modules which I think is a valid use case, especially internally at Esri. Is is also still helpful over CDN because you can drop it into CodePens dependencies and while you CAN use ES modules (#788) I don't think people are super familiar with using them in a context like CodePen yet. Maybe we do this:
If we feel like accelerating things we can always do
There is some push back against switching everything to ESM only too soon (in Node) node-fetch/node-fetch#1263 and sindresorhus/meta#15. |
@alaframboise @ak-kemp Summarizing this for you here since this will be a major change in the doc at 4.0. We are going to merge Current 3.x https://developers.arcgis.com/documentation/mapping-apis-and-services/search/geocoding/#geocode-an-address import { geocode } from "@esri/arcgis-rest-geocoding"
import { APIKey } from "@esri/arcgis-rest-auth"
geocode({
address: "1600 Pennsylvania Ave NW, DC",
authentication: new APIKey("YOUR_API_KEY"),
}).then(response => {
response.candidates[1].location // => { x: -77.036533, y: 38.898719, spatialReference: ... }
}) Future 4.0 import { geocode } from "@esri/arcgis-rest-geocoding"
import { APIKey } from "@esri/arcgis-rest-request"
geocode({
address: "1600 Pennsylvania Ave NW, DC",
authentication: new APIKey("YOUR_API_KEY"),
}).then(response => {
response.candidates[1].location // => { x: -77.036533, y: 38.898719, spatialReference: ... }
}) |
@patrickarlt seems very odd to call a variable APIKey for a request module ref.. doesn't make sense to me. When is this planned for? I was going to create a rest js/location services video soon but I'll shelf it. |
@alaframboise We are merging
I don't really think It is worth noting 2 additional things:
|
You don't get an I'm find with everything else. |
@alaframboise I don't understand can you elaborate on this? |
@alaframboise you mean that if you do: const myAPIkey = new APIKey("AAPK..."); You would expect to get a new API key item not create a session object for |
@patrickarlt yes exactly. If I create an instance of a |
Just adding my two cents: Would it make more sense to rename |
@alaframboise @noahmulfinger moving discussion about renaming the |
I've merged |
Currently just about every package has 2
peerDependencies
: request and auth. In my experiencepeerDependencies
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):We should remove those dependencies.
Second, arcgis-rest-service-admin only
import
sIUserRequestOptions
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 underdevDependencies
, 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 theUserSession
class to the types package. We could move the dependency underdevDependencies
, but it would be up to us to make sure we don't introduce any runtime uses (likenew UserSession()
). Seems a bit risky. Maybe we just leave it as underpeerDependencies
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."The text was updated successfully, but these errors were encountered: