Registry / serialization / babel-plugin-transform-object-spread-inline

babel-plugin-transform-object-spread-inline

JSON →
library0.0.3jsnpmunverified

A Babel plugin that transpiles object spread syntax into inline assignments and for loops using Object.keys, avoiding the slower for...in with hasOwnProperty check. Version 0.0.3 appears to be the latest, with no recent updates. It provides a performance alternative to the default babel-plugin-transform-object-rest-spread by generating faster code for object spreads, especially when only one spread is used. Note that it does not handle object rest syntax and may not be suitable for multiple spreads per object.

npm install babel-plugin-transform-object-spread-inline
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-object-spread-inline
serializationjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
// Add to .babelrc plugins array: "transform-object-spread-inline"
require('babel-plugin-transform-object-spread-inline')
This is a Babel plugin, not imported in source code. It's configured in .babelrc or babel.config.js.
default (from npm)
npm install --save-dev babel-plugin-transform-object-spread-inline
npm install babel-plugin-transform-object-spread-inline
Must be saved as a devDependency, not a regular dependency.

Shows installation, configuration, and transformation of object spread into faster inline code using Object.keys.

// Install plugin npm install --save-dev babel-plugin-transform-object-spread-inline // .babelrc configuration { "plugins": ["transform-object-spread-inline"] } // Input source const a = { b, c, ...d, e, f: 42 }; // Output (compiled) "use strict"; var _keys, _l, _i, _source, _key, _result = {}; _result.b = b; _result.c = c; for (_source = d, _keys = Object.keys(_source), _l = _keys.length, _i = 0; _i < _l; _i++) { _key = _keys[_i]; _result[_key] = _source[_key]; } _result.e = e; _result.f = 42; a = _result;
Debug
Known issues
gotchaThis plugin does not transpile object rest syntax (e.g., const { a, ...rest } = obj).
fix
Use a separate plugin like @babel/plugin-proposal-object-rest-spread for rest syntax.
affects: all
gotchaUsing multiple spread operators in a single object literal will generate multiple loops, potentially negating performance benefits.
fix
Minimize the number of spreads per object, or avoid this plugin if many spreads are used.
affects: all
deprecatedThe plugin has not been updated recently and may not be compatible with newer Babel versions (e.g., Babel 7+).
fix
Consider using @babel/plugin-proposal-object-rest-spread with built-in optimization or use modern Babel presets.
affects: >=0.0.3
gotchaThe plugin's transformation uses Object.keys, which does not include inherited enumerable properties, unlike for...in.
fix
If you need inherited properties, do not use this plugin and stick with the standard plugin.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-object-spread-inline'
Plugin not installed or not in node_modules.
fix
Run: npm install --save-dev babel-plugin-transform-object-spread-inline
SyntaxError: Unexpected token ...
Babel is not configured to use the plugin, or the source contains rest syntax not spread.
fix
Ensure the plugin is in .babelrc 'plugins' array and check for rest patterns; use separate plugin for rest.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
14
OpenAI (training)
1
Resources
babel-plugin-transform-object-spread-inline — npm install babel-plugin-transform-object-spread-inline · libregistry