ecmascript 6 - Why does Object.assign not appear to work on Safari 8.0.7? -
we're writing app using webpack , babel-core 5.8.25
.
at 1 point in time, happens:
somearray.map(item => { const updateditem = object.assign({}, item); // silently fails here... doesn't continue code updateditem.prop = 'something cool'; });
this compiled before hitting browser. works in latest version of chrome , latest version of ios safari, in safari 8.0.7
, fails silently (no error thrown... doesn't go past line).
this, however, works expected (using lodash):
somearray.map(item => { const updateditem = _.extend({}, item); // important part updateditem.prop = 'something cool'; });
any idea? tried poking around internet regarding this, no avail.
object.assign
works in chrome because chrome supports natively. babel-loader
on own converts es6 syntax es5 syntax, not make es6 library functionality available. easiest way webpack change config like
entry: 'app.js'
to
entry: ['babel-core/polyfill', 'app.js'] // or babel 6: entry: ['babel-polyfill', 'app.js']
so webpack bundle , run polyfill before executing application. babel provides /polyfill
easy way load polfill, optional because not wants use it, , because there many polyfills available , 1 babel uses, core-js
1 of many.
Comments
Post a Comment