Babel Preset does not provide support on IE11 for Object.assign - “Object doesn't support property or method 'assign'”

前端 未结 2 428
清酒与你
清酒与你 2021-02-01 15:50

I am using babel-preset-env version - 1.6.1 for my react app, i am getting a error on IE :- Object doesn\'t support property or method \'assign\'

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 16:53

    Babel Polyfill is outdated as of Babel 7.4.0

    (Source)

    Please use core-js instead.

    import "core-js/stable";
    import "regenerator-runtime/runtime";
    

    Or with Webpack:

    module.exports = {
      entry: ["core-js/stable", "regenerator-runtime/runtime", "./app/main"]
    }
    

    In my case the above webpack config did not work! because I was also lacking a promise polyfill. This is the webpack.config I ended up using:

    entry: { 'main': ['core-js/fn/promise', 'core-js/stable/object/assign', './wwwroot/src/app.js'] },
    

提交回复
热议问题