-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unexport or document mapboxgl.util #1408
Comments
Can we leave it public but undocumented? There are some methods in there that are useful for libraries extending gl-js like in |
fwiw Leaflet's utils are public and they help leaflet's plugins have a vanilla way to do basic stuff like building 3rd party controls |
@kelvinabrokwa gl-js doesn't do "public but undocumented". The choices are either private (and preferably still documented), or public and documented. If there's an undocumented public API, it's a bug. Committing to something as public API has costs:
gl-js is not a general utility library. Its API should focus on maps, and leave methods which are easily found in myriad third party modules, to those modules. Something like |
One potential compromise is to kill |
Based on Leaflet experience, the costs are not that bad. Higher standard of docs and tests is beneficial in general regardless of whether it is applied to public APIs or not. I also had no problem breaking compatibility on many util methods and no one ever complained — it's fine as long as it is clearly described in the changelog. There were also never any attempts to make the util methods more generic — they were always kept focused on Leaflet needs, nevertheless they turned out to be useful for users too. Many plugin devs also depend on them. It also feels uneasy to use a third-party util library in your app for stuff that's already in the bundle but can't be used because it wasn't exported, thus duplicating code. |
+1 @lucaswoj's comment. A lot of this could go into a third party lib. What can't could be private. as an ie: https://github.com/component/debounce |
I think it is worth resuming this discussion. I'm still in favor of using a 3rd party utility lib like lodash.
|
I'm 👎 on Lodash, it's bloatware in my opinion and we've been perfectly fine with the current situation, with a minimal set of utils specific to GL JS. |
I'm ok with that. |
To expand on this, in it's entirety it's 21kb gzipped, which is a lot for a few utility methods. 4kb is just the core build. Also, our dependency tree is already heavy, and Lodash is like 4MB alone in node_modules... And if we use separate small modules, it's a dependency hell to manage. |
The original question here wasn't "should we use lodash or not", it was "should mapbox-gl-js export general-purpose utility methods". My opinion is still "no": mapbox-gl-js should export only functionality specific to maps. Exporting general purpose utilities, while perhaps convenient in certain cases, means more work for mapbox-gl-js developers, and exposes internal implementation details we may want to change in the future. |
My opinion is still "yes": mapbox-gl-js should leave util exported and document it. Making a method public doesn't mean we are obliged to make it general-purpose — it's enough to document its specifics, which should be documented anyway. If we want to change implementation details in future, it's not a problem — minor breaking changes happen, and they don't cause much trouble if documented. |
If the utilities are useful for plugin development they should be exported. |
Examples of
We want the freedom to drop functions like this once we no longer need them. The library should not export |
@jfirebaugh I'm sold, let's unexport. |
Yep, I agree too. |
Nothing there is public.
The text was updated successfully, but these errors were encountered: