{"id":19117,"library":"babel-plugin-object-assign","title":"babel-plugin-object-assign","description":"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+.","status":"deprecated","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/babel-plugins/babel-plugin-object-assign","tags":["javascript","babel","babel-plugin","object","assign","extend","polyfill"],"install":[{"cmd":"npm install babel-plugin-object-assign","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-object-assign","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-object-assign","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required as a peer dependency; the plugin uses Babel 5 plugin API","package":"babel-core","optional":false}],"imports":[{"note":"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.","wrong":"const plugin = require('babel-plugin-object-assign'); require('babel').transform(code, { plugins: [plugin] })","symbol":"plugin","correct":"require('babel').transform(code, { plugins: ['object-assign'] })"},{"note":"Babel 5 does not support ES module import for plugins; always use the string name.","wrong":"import plugin from 'babel-plugin-object-assign'; Babel.transform(code, { plugins: [plugin] })","symbol":"plugin as ES module","correct":"import Babel from 'babel'; Babel.transform(code, { plugins: ['object-assign'] })"},{"note":"For browserify/babelify, pass the plugin as a string; do not require the module.","wrong":"babelify.configure({ plugins: [require('babel-plugin-object-assign')] })","symbol":"plugin with babelify","correct":"babelify.configure({ plugins: ['object-assign'] })"}],"quickstart":{"code":"// Install: npm install babel@5 babel-core@5 babel-plugin-object-assign\n// Run: babel --plugins object-assign script.js\n\n// Example script.js content before transformation:\nconst merged = Object.assign({ a: 1 }, { b: 2 });\n\n// After transformation with the plugin:\n// The output will use the internal extends helper instead of Object.assign.\n// This ensures compatibility with older browsers without native Object.assign.\n\n// Programmatic usage:\nconst babel = require('babel');\nconst result = babel.transform('const x = Object.assign({}, { y: 1 });', {\n  plugins: ['object-assign']\n});\nconsole.log(result.code); // Output uses _extends helper","lang":"javascript","description":"Demonstrates install, CLI usage, and programmatic transform with Babel 5."},"warnings":[{"fix":"Upgrade to a different approach: use @babel/plugin-transform-object-assign for Babel 7, or include a polyfill like core-js.","message":"Plugin only works with Babel 5.x (babel-core >=5.6.0). It is not compatible with Babel 6 or later versions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Migrate to Babel 7 and use @babel/plugin-transform-object-assign or @babel/preset-env with core-js.","message":"This plugin is deprecated and no longer maintained. Babel 5 itself has been superseded.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Combine with other Babel plugins or a polyfill for complete coverage.","message":"The plugin replaces Object.assign only; it does not polyfill other Object methods or provide a full ES2015+ environment.","severity":"gotcha","affected_versions":"all"},{"fix":"Use babelify.configure({ plugins: ['object-assign'] })","message":"When using browserify with babelify, the plugin must be specified as a string in the configure options; passing the plugin object directly may fail silently.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"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.","cause":"Plugin not installed or Babel 6+ trying to resolve it incorrectly.","error":"Cannot find module 'babel-plugin-object-assign'"},{"fix":"Downgrade to Babel 5 or use a compatible replacement.","cause":"Plugin loaded with newer Babel version that changed the API.","error":"TypeError: Cannot read property 'traverse' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}