-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Sparked by a comment by @etpinard #3254 (comment):
It might be nice to make a distinction between "registerable" (i.e optional) component modules (e.g.
annotations/,shapes/) and component modules that are mostly intended to DRY things up (e.g.color/,colorscale/... and the soon-to-beaxes/). Maybe the latter could be placed in different directory e.g.src/common/and leavesrc/components/for "registerable" modules?
Completely agree we should be clearer about what components/ means. My gut reaction is actually to go even further: common/ serves the same role as lib/, and lib/ itself has perhaps outgrown its origin as a flat directory that exports everything in one namespace. In fact it already doesn't do this, these files are in lib/ but not incorporated in lib/index:
clear_gl_canvases, events, geo_location_utils, geojson_utils, gl_format_color, gup, override_cursor, polygon, prepare_regl, queue, show_no_webgl_msg, str2rgbarray, svg_text_utils, topojson_utils
So my proposal:
lib/indexshould only contain small functions that have no dependencies on anything else in our codebase (exceptconstants/; currently it also importsd3andfast-isnumeric, those seem fine), so it can be safely imported by anyone including other files insidelib/, and it should not import anything else fromlib/. This would require most consumers oflib/to pull in the individual pieces they need rather than justrequire('../../lib')- that's probably the most controversial part of this proposal, as it would be a bunch of work, but I think it would be an improvement in terms of being explicit about imports, and it would let us 🔪 dumb files likelib/modandlib/noopthat exist only so otherlibconsumers can import them. It could also reduce the size of partial bundles a little bit.- We move unregisterable "components" to be subdirectories of
lib/ - We try to group other files in
libinto subdirectories too - in fact some of the above-mentionedlibfiles could go intocomponents/color -> lib/color- but I also don't see anything wrong with leaving some hard-to-categorize files directly inlib/.