mapbox / gazetteer

Place bookmarks for maps
BSD 2-Clause "Simplified" License
10 stars 8 forks source link

Add build step, change import patterns #52

Closed dasulit closed 4 years ago

dasulit commented 5 years ago

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:

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?

tristen commented 5 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?

dasulit commented 5 years ago

@tristen that's possible, but the paths seemed unwieldy to me πŸ˜• do you not think so?

tristen commented 5 years ago

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?

dasulit commented 4 years ago

@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?