{"id":19219,"library":"babel-plugin-transform-replace-object-assign","title":"babel-plugin-transform-replace-object-assign","description":"This Babel plugin replaces all `Object.assign` calls with a custom implementation specified via the `moduleSpecifier` option, importing the shim from an npm package. At version 2.0.0 (latest release, last updated in 2018), the plugin requires `@babel/core@^7.0.0` as a peer dependency. It is similar to `babel-plugin-transform-object-assign` but allows using an external package (e.g., `object-assign`) instead of Babel's internal `_extends` helper, reducing bundle size by avoiding per-file function declarations. However, the plugin is explicitly deprecated by the author: the original Chrome bug it addressed (V8 issue #4118) has been fixed since Chrome 49. The plugin remains functional but is discouraged for new projects; developers should consider native `Object.assign` or `babel-plugin-transform-object-assign` instead.","status":"deprecated","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/newoga/babel-plugin-transform-replace-object-assign","tags":["javascript","assign","babel","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-transform-replace-object-assign","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-replace-object-assign","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-replace-object-assign","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required as the Babel environment for the plugin to run.","package":"@babel/core","optional":false}],"imports":[{"note":"Add to Babel config as a plugin; the option `moduleSpecifier` is optional and defaults to \"object-assign\". No direct JavaScript import needed.","wrong":"plugins: [\"transform-replace-object-assign\"] (will use default moduleSpecifier, but may not be intended)","symbol":"transform-replace-object-assign","correct":"plugins: [[\"transform-replace-object-assign\", { \"moduleSpecifier\": \"object-assign\" }]]"},{"note":"The implementation package is imported at build time; ensure it is in dependencies.","wrong":"npm install --save-dev object-assign (should be regular dependency if used at runtime)","symbol":"object-assign (runtime package)","correct":"npm install --save object-assign"},{"note":"Output uses ESM import; compatible with bundlers. No manual import required.","wrong":"import _objectAssign from 'object-assign'; (no common mistake, but output is auto-generated)","symbol":"object-assign (import in output)","correct":"import _objectAssign from 'object-assign';"}],"quickstart":{"code":"// Install\nnpm install --save-dev @babel/core babel-plugin-transform-replace-object-assign\nnpm install --save object-assign\n\n// .babelrc\n{\n  \"plugins\": [\n    [\"transform-replace-object-assign\", { \"moduleSpecifier\": \"object-assign\" }]\n  ]\n}\n\n// Input: src/index.js\nObject.assign({}, { foo: 'bar' });\n\n// Build output (after Babel transform):\nimport _objectAssign from 'object-assign';\n_objectAssign({}, { foo: 'bar' });\n\n// Note: Default option is { \"moduleSpecifier\": \"object-assign\" } so config can be simplified to:\n{\n  \"plugins\": [\"transform-replace-object-assign\"]\n}","lang":"javascript","description":"Install the plugin and a custom Object.assign implementation, configure Babel, and see how Object.assign is replaced with an import of the custom package."},"warnings":[{"fix":"Use native Object.assign (ES6) or babel-plugin-transform-object-assign if you need runtime shimming.","message":"Plugin explicitly deprecated by author: original Chrome bug (V8 #4118) fixed in Chrome 49, making plugin unnecessary for its original purpose. Author advises against use unless you have a specific need.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure the specified package is in your dependencies and correct.","message":"The moduleSpecifier option must be a package available at runtime; if omitted, defaults to 'object-assign', which must be installed as a dependency.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you need to replace all uses, consider using a different approach like babel-plugin-transform-object-assign which uses the _extends helper.","message":"Plugin only replaces direct calls to Object.assign (e.g., Object.assign(a, b)) — not polyfills or re-assignments. Code that uses Object.assign as a value (e.g., var assign = Object.assign) will not be transformed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If using Babel 6, stick with version 1.x of this plugin.","message":"Major version 2.0.0 requires @babel/core ^7.0.0 (Babel 7) and is not compatible with Babel 6.","severity":"breaking","affected_versions":"^2.0.0"},{"fix":"Consider alternatives like babel-plugin-transform-object-assign or @babel/plugin-transform-object-assign (Babel 7 core).","message":"Plugin has not been updated since 2018 — no fix for potential future Babel core changes.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.0':33 '2018':39 '4118':103 '49':109 '7.0.0':44 'address':100 'allow':60 'assign':7,58,68,131,134 'author':94 'avoid':80 'babel':2,9,54,71,127,135,137 'babel-plugin':136 'babel-plugin-transform-object-assign':53,126 'babel-plugin-transform-replace-object-assign':1 'babel/core':43 'bug':98 'bundl':77 'call':14 'chrome':97,108 'consid':122 'custom':17 'declar':85 'depend':48 'deprec':91 'develop':120 'discourag':116 'e.g':65 'explicit':90 'extend':74 'extern':63 'file':83 'fix':106 'function':84,113 'helper':75 'howev':86 'implement':18 'import':24 'instead':69,132 'intern':73 'issu':102 'javascript':133 'last':36 'latest':34 'modulespecifi':22 'nativ':123 'new':118 'npm':29 'object':6,57,67,130 'object-assign':66 'object.assign':13,124 'option':23 'origin':96 'packag':30,64 'peer':47 'per':82 'per-fil':81 'plugin':3,10,41,55,88,111,128,138 'project':119 'reduc':76 'releas':35 'remain':112 'replac':5,11 'requir':42 'shim':26 'similar':51 'sinc':107 'size':78 'specifi':19 'transform':4,56,129 'updat':37 'use':61 'v8':101 'version':32 'via':20","created_at":"2026-04-25T11:16:39.989193+00:00","updated_at":"2026-04-25T11:16:39.989193+00:00","problems":[{"fix":"Run: npm install --save-dev babel-plugin-transform-replace-object-assign","cause":"Plugin not installed or not listed correctly in Babel config.","error":"Error: Could not find plugin \"transform-replace-object-assign\". Ensure there is an entry in ./node_modules/babel-plugin-transform-replace-object-assign"},{"fix":"Run: npm install --save object-assign","cause":"Default moduleSpecifier 'object-assign' not installed as a runtime dependency.","error":"Error: Cannot find module 'object-assign'"},{"fix":"Ensure the moduleSpecifier package is in dependencies, not devDependencies.","cause":"Plugin transforms code but the custom assign package is not available at runtime because it's only in devDependencies or missing.","error":"TypeError: Object(...) is not a function (or similar at runtime if object-assign not imported properly)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/newoga/babel-plugin-transform-replace-object-assign","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-plugin-transform-replace-object-assign","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}