Closed dasulit closed 4 years ago
Is another option not writing a dist script and requiring a user to request gazetteers by writing path out in the require like this https://runkit.com/embed/r8dw0kvjn0bp?
Instead of @mapbox/gazetteer/mapbox-streets/natural-label.json
with reorganization it could be @mapbox/gazetteer/locations/global/natural-label.json
?
@tristen that's possible, but the paths seemed unwieldy to me π do you not think so?
Just spitballing but something like this could be nice?
import { global, japan } from '@mapbox/gazetteer/locations'
const { transit, buildings } = global;
So each directory under locations would have its own index.js
that exports all the gazetteers within the directory?
module.exports = {
transit: require('./transit'),
buildings: require('./buildings')
};
cc/ @mapbox/map-design-team for other ideas?
@tristen HELLO! 1 month later, giving this another pass π the latest commit strips out all of the build nonsense, and reflects your most recent proposal. Would you mind reviewing to see if this looks as expected to you?
This is a first shot at reorganizing this project a little bit. π€
@tristen I would love for an initial high-level review of the strategy here! I have no idea if this is conventional and am very open to changing paths if you have ideas. Of note is the
build-dist
script, which does the following:src/gazetteer
subdirectories and (minified) files indist
.index.js
at the root ofdist
with exports for all those gazetteers (maybe this is bad?).src/util
files todist
. The exports for utils are manually maintained insrc
, but merged into thedist/index.js
file mentioned above (maybe this is bad?).At the end of the day imports then look like:
import { globalTransit, lint } from '@mapbox/gazetteer'
My initial goal was to have nested paths with default exports like:
import transit from '@mapbox/gazetteer/transit'
but there isn't really a straightforward way to accomplish this without an over-the-top build script. So landing on named exports, though I don't love the export names and would be very open to other ideas.If you πthe approach, I can address the rest of https://github.com/mapbox/gazetteer/issues/51 and maybe https://github.com/mapbox/gazetteer/issues/48. If not, maybe we can workshop some alternatives?