@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
orObject['assign']
. The following patterns are not supported:JavaScriptvar { assign } = Object;
var assign = Object.assign;
Installation
- npm
- Yarn
npm install --save-dev @babel/plugin-transform-object-assign
yarn add --dev @babel/plugin-transform-object-assign
Usage
With a configuration file (Recommended)
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"],
});