-
Notifications
You must be signed in to change notification settings - Fork 1.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
Polyfills for IE11 / PhantomJS #6087
Comments
I'm using the browser-polyfills which seems to have everything we need.
|
(re: #6087) I ran into some trouble here, it looks like `Array.from()` polyfill doesn't work for Sets in PhantomJS
Just a heads up that I ended up doing this, but I don't want to do it everywhere Lines 316 to 332 in 0c7d986
|
#6087 (comment) Also added `npm run phantom` to test workarounds like this quickly
I've been working on this for a few days and it's really nice to have our lodash usage trimmed down significantly. Here's what's left:
|
(re: #6087) Tests in Phantom run twice as fast now!
(re #6087) - some were able to do a different approach (validations/almost_junction, and settings/*) - some were replaced with custom speedy cloners (in orthogonalize clonePoints and osm.js cloneNoteCache) - some just replaced with JSON.parse(JSON.stringify()))
This was done! 😅 To recap:
Most of iD's large bundle size now is because of the data that we bundle into iD. This includes: the presets (particularly the name-suggestion-index which is big now), the imagery index, the community index, the English strings, and the intro walkthrough data (the biggest chunk on that chart). These are all things we can load separately once we focus on splitting iD into small modules for iD v3. |
We really need to start weaning our way off Lodash.
I'm not providing the before/after flamecharts, but this change in
coreGraph
made a substantial performance improvement in Chrome:All modern browsers support
Object.assign
, but we have used Lodash's_assign
to support legacy browsers like IE11 and PhantomJS (which runs our tests).I'm going to use this ticket to list specific things that we'll remove from the iD code and replace with browser-native equivalents. No we're not going full ES6 or introducing Babel transpilation, so don't ask for that.
_.assign()
->Object.assign
_.clone()
->Object.assign({} , thing)
orArray.slice
_.compact()
->Array.filter(Boolean)
_.extend()
->Object.assign
(subtly different from_.assign()
)_.every()
->Array.every
_.filter()
->Array.filter
_.find()
->Array.find
_.findIndex()
->Array.findIndex
_.includes()
->Array.indexOf !== -1
_.indexOf
->Array.indexOf
_.isFunction
->typeof thing === 'function'
_.keys()
->Object.keys
_.omit()
->Object.keys(obj).reduce
trick - do this_.pull()
->Array.filter
(likeremove
, and mutate array)_.reject()
->Array.filter
(with inverted predicate)_.remove()
->Array.filter
(with inverted predicate, and mutate the array)_.some()
->Array.some
_.values()
->Object.values
_.without()
->Array.filter
(likeremove
but return a new array, whichfilter
does)Array helpers can be implemented with
Set
- do this_.difference()
_.intersection()
_.union()
_.uniq()
and add util functions to replace
_.chunk()
_.groupBy()
_.uniqBy()
The text was updated successfully, but these errors were encountered: