Registry / devops / babel-plugin-object-assign

babel-plugin-object-assign

JSON →
library1.2.1jsnpmunverified

A Babel plugin for Babel 5.x that transforms Object.assign() calls into the internal extends helper, reducing the need for polyfills or libraries like _.extend. Version 1.2.1 is the current stable release, designed specifically for Babel 5 (babel-core >=5.6.0). It is a simple, focused plugin with no updates since 2015. Key differentiator: works at the AST level to replace Object.assign with a lightweight helper, avoiding runtime polyfills. Not compatible with Babel 6+.

npm install babel-plugin-object-assign
INSTALL
IMPORT
SIG · BABEL-PLUGIN-OBJEC
B
babel-plugin-object-assign
devopsjavascriptv1.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
require('babel').transform(code, { plugins: ['object-assign'] })
const plugin = require('babel-plugin-object-assign'); require('babel').transform(code, { plugins: [plugin] })
Use the plugin by its string name 'object-assign' in Babel 5 options; requiring the module directly and passing it as an object may not work correctly.
plugin as ES module
import Babel from 'babel'; Babel.transform(code, { plugins: ['object-assign'] })
import plugin from 'babel-plugin-object-assign'; Babel.transform(code, { plugins: [plugin] })
Babel 5 does not support ES module import for plugins; always use the string name.
plugin with babelify
babelify.configure({ plugins: ['object-assign'] })
babelify.configure({ plugins: [require('babel-plugin-object-assign')] })
For browserify/babelify, pass the plugin as a string; do not require the module.

Demonstrates install, CLI usage, and programmatic transform with Babel 5.

// Install: npm install babel@5 babel-core@5 babel-plugin-object-assign // Run: babel --plugins object-assign script.js // Example script.js content before transformation: const merged = Object.assign({ a: 1 }, { b: 2 }); // After transformation with the plugin: // The output will use the internal extends helper instead of Object.assign. // This ensures compatibility with older browsers without native Object.assign. // Programmatic usage: const babel = require('babel'); const result = babel.transform('const x = Object.assign({}, { y: 1 });', { plugins: ['object-assign'] }); console.log(result.code); // Output uses _extends helper
Debug
Known issues
breakingPlugin only works with Babel 5.x (babel-core >=5.6.0). It is not compatible with Babel 6 or later versions.
fix
Upgrade to a different approach: use @babel/plugin-transform-object-assign for Babel 7, or include a polyfill like core-js.
affects: >=1.0.0
deprecatedThis plugin is deprecated and no longer maintained. Babel 5 itself has been superseded.
fix
Migrate to Babel 7 and use @babel/plugin-transform-object-assign or @babel/preset-env with core-js.
affects: >=1.0.0
gotchaThe plugin replaces Object.assign only; it does not polyfill other Object methods or provide a full ES2015+ environment.
fix
Combine with other Babel plugins or a polyfill for complete coverage.
affects: all
gotchaWhen using browserify with babelify, the plugin must be specified as a string in the configure options; passing the plugin object directly may fail silently.
fix
Use babelify.configure({ plugins: ['object-assign'] })
affects: all
Errors
Common errors & fixes
Cannot find module 'babel-plugin-object-assign'
Plugin not installed or Babel 6+ trying to resolve it incorrectly.
fix
Ensure you are using Babel 5 (babel-core@5) and have the plugin in node_modules. For Babel 6+, use @babel/plugin-transform-object-assign.
TypeError: Cannot read property 'traverse' of undefined
Plugin loaded with newer Babel version that changed the API.
fix
Downgrade to Babel 5 or use a compatible replacement.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
babel-corerequiredrequired as a peer dependency; the plugin uses Babel 5 plugin API
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-object-assign — npm install babel-plugin-object-assign · libregistry