npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

babel-plugin-transform-replace-object-assign

v2.0.0

Published

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

Downloads

55,810

Readme

babel-plugin-transform-replace-object-assign

All Contributors 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.


⚠️ Important note on the use of this project:

Most likely you do not and should not use this plugin! I initially wrote this plugin due to a bug in Chrome where key order was not gaurenteed to be correct for objects mutated with Object.assign (the issue is also described at sindresorhus/object-assign#22).

While the bug did not cause problems for most projects, it did causes problems for a project I was helping maintain (Material-UI). We heavily used Object.assign to merge style definitions that were defined in javascript objects. Since key order is important when defining CSS style rules, the Object.assign implementation built into Chrome caused many style related bugs. This plugin allowed us to completely replace all uses of Object.assign within our source code with an implementation that did not break in Chrome (with the expectation that we would stop using this plugin when the bug was fixed and rolled out to a majority of Chrome users).

The bug in Chrome has been fixed for quite some time now (it was fixed in Chrome 49), so this plugin is no longer necessary for the purpose it was originally created for. We have also stopped using this plugin for Material-UI. Please carefully consider the necessity and implications of replacing all of your Object.assign calls before using this plugin. If you are not sure if you need this, feel free to open an issue to discuss it.


Usage

Installation

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

# Install an assign implementation
$ npm install object-assign

Configure

When you provide the plugin, use the moduleSpecifier option to specify which package you would like imported and used when replacing Object.assign.

.babelrc

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

To use defaults (which is the same as above):

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

Result

In

Object.assign(a, b);

Out

import _objectAssign from 'object-assign';

_objectAssign(a, b);

Contributors

Thanks goes to these wonderful people (emoji key):

| Neil Gabbadon💻 📖 | Ivan Nikolić🐛 | Jordan Harband🤔 | Jayden Seric💻 📖 | | :---: | :---: | :---: | :---: |

This project follows the all-contributors specification. Contributions of any kind welcome!