Why does Object.assign not appear to work on Safari 8.0.7?

后端 未结 1 798
忘掉有多难
忘掉有多难 2021-01-05 08:38

We\'re writing an app using webpack and babel-core 5.8.25.

At one point in time, this happens:

someArray.map(item => {
  const update         


        
相关标签:
1条回答
  • 2021-01-05 09:18

    Object.assign works in Chrome because Chrome supports it natively. babel-loader on its own only converts ES6 syntax to ES5 syntax, it does not do anything to make ES6 library functionality available. The easiest way to do that with Webpack is to change your config from something like

    entry: 'app.js'
    

    to

    entry: ['babel-core/polyfill', 'app.js']
    
    // Or with Babel 6:
    entry: ['babel-polyfill', 'app.js']
    

    so that Webpack will also bundle and run the polyfill before executing your application. Babel provides /polyfill as an easy way to load the polfill, but it is optional because not everyone wants to use it, and because there are many polyfills available and the one Babel uses, core-js is just one of many.

    0 讨论(0)
提交回复
热议问题