-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Refactor into smaller modules #154
Comments
Work is ongoing in the This restructures the existing single JavaScript file into a number of smaller modules. The bulk of the geocoder logic is in
By depending on third-party libraries, we do observe a sizable increase in library file size, from about 20kb minified (6kb minified+gzipped) to about 30kb minified (8kb minified+gzipped). Typically, a 50% increase in library size should be cause for concern. However, we are making this decision trading off against other gains:
The entry point for the library is now // v1.8.0 or earlier
// L.Control.Geocoder is created as a side-effect of require()
require('leaflet-geocoder-mapzen')
// ...
var geocoder = new L.Control.Geocoder()
// v1.9.0 (and future)
// The require() value can now be set to a variable.
var MyGeocoder = require('leaflet-geocoder-mapzen')
// ...
var geocoder = new MyGeocoder()
// Note that the side-effect of attaching to L.Control.Geocoder still occurs, so as to not break existing code. If you want to completely prevent side effects, (e.g. for mapzen.js), your import code should import // Requiring only the base container (no L namespace)
var Geocoder = require('leaflet-geocoder-mapzen/src/core')
// or in ES2015
import Geocoder from 'leaflet-geocoder-mapzen/src/core'
// ...
const geocoder = new Geocoder()
const nope = new L.Control.Geocoder() // will be undefined Note that the In keeping with semantic versioning, I would like to make sure this does not break any existing uses. Because the code architecture has changed, we must do a little bit of ground work to make sure this is the case. (If code breaks and it turns out to be insurmountable, this will be a v2 release, and not v1.9.0.). To test this, please install this branch as a Node module: npm install git://github.com/mapzen/leaflet-geocoder.git#bundle Be sure to test this out first without updating your existing code, and then update your code if you wish to try the new import/require features. |
Update: to preserve IE8 functionality we are importing the previous utility functions instead of Lodash. (note: we can put back Lodash and drop IE8 compatibility in v2.) |
Update: we can incorporate |
1.9.0 released in 8ae16b1. |
Goal: enables cleaner import by mapzen.js.
The text was updated successfully, but these errors were encountered: