Registry /
devops / babel-plugin-object-assign
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
muslnode 18–226 runs
build_error
glibcnode 18–226 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
Errors
Common errors & fixes
Cannot find module 'babel-plugin-object-assign'
Plugin not installed or Babel 6+ trying to resolve it incorrectly.
fixEnsure 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.
fixDowngrade to Babel 5 or use a compatible replacement.
Audit
Dependencies
babel-corerequiredrequired as a peer dependency; the plugin uses Babel 5 plugin API