JSPM

babel-plugin-transform-replace-object-assign

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13230
  • Score
    100M100P100Q156852F
  • License MIT

Allows you to provide custom implementation of Object.assign in babel builds

Package Exports

  • babel-plugin-transform-replace-object-assign

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-transform-replace-object-assign) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-plugin-transform-replace-object-assign

Build Status npm version npm downloads

Replaces Object.assign with a custom implementation that you provide in plugin configuration. This plugin works similarly to the babel-plugin-transform-object-assign plugin except it allows you to provide your own implementation that you would like to replace Object.assign with rather than the _extends helper that Babel uses.

Also, this plugin will import an external package in files where Object.assign is used rather than redeclaring the function in each file (which should help reduce bundle size). This is ultimately what babel-plugin-transform-runtime does for you when using the _extends helper.

The implementation you configure is specified as a npm package dependency.

Usage

Installation

# Install the plugin
$ npm install babel-plugin-transform-replace-object-assign

# Install an assign implementation
$ npm install lodash.assign

Configure

When you provide the plugin, also specify which package you would like imported and used when replacing Object.assign.

.babelrc

{
  "plugins": [
    ["transform-replace-object-assign", "lodash.assign"]
  ] 
}

Result

In

Object.assign(a, b);

Out

import _lodash from 'lodash.assign';

_lodash(a, b)