Object.assign transform

Replace Object.assign with an inline helper

If you are authoring an application, rather than a library, it is recommended that you use the Object.assign polyfill instead.

实例

输入

Object.assign(a, b);

输出

var _extends = ...;

_extends(a, b);

注意事项

  • 只能使用 Object.assign 或 Object[‘assign’] 形式的代码。不支持以下方式:

    var { assign } = Object;
    var assign = Object.assign;
    

安装

npm install --save-dev babel-plugin-transform-object-assign

用法

通过 .babelrc(推荐)

.babelrc

{
  "plugins": ["transform-object-assign"]
}

通过 CLI

babel --plugins transform-object-assign script.js

通过 Node API

require("babel-core").transform("code", {
  plugins: ["transform-object-assign"]
});