Skip to main content

@babel/plugin-transform-object-assign

Example

In

JavaScript
Object.assign(a, b);

Out

JavaScript
var _extends = ...;

_extends(a, b);

Caveats

  • Will only work with code of the form Object.assign or Object['assign']. The following patterns are not supported:

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

Installation

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

Usage

babel.config.json
{
"plugins": ["@babel/plugin-transform-object-assign"]
}

Via CLI

Shell
babel --plugins @babel/plugin-transform-object-assign script.js

Via Node API

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