object-assign-native

native Object.assign as a cjs module export for bundler replacement of object-assign

Usage no npm install needed!

<script type="module">
  import objectAssignNative from 'https://cdn.skypack.dev/object-assign-native';
</script>

README

object-assign-native

Some libraries (e.g. React) don't want to rely on the user polyfilling Object.assign and therefore use sindresorhus's ponyfill object-assign although all modern browser and nodejs versions support it flawlessly.

While not a noticeable in size for most apps it is still half a kb minified and gziped that isn't necessary. Luckily most bundlers allow for modules to be replaced at build time with another one.

Webpack

When using webpack just add the following lines to your config:

const webpack = require("webpack");
// ...
  plugins: [
    new webpack.NormalModuleReplacementPlugin(
      /^object-assign/,
      "object-assign-native"
    )
  ]
// ...