Registry / devops / babel-plugin-object-rest-spread

babel-plugin-object-rest-spread

JSON →
library0.0.0jsnpmunverified

A Babel plugin that transforms object rest/spread properties (stage-2 proposal) to ES5-compatible code. This package is a fork of @babel/plugin-proposal-object-rest-spread that removes the dependency on transform-es2015-destructuring, offering a lightweight alternative. It supports loose mode and extends helper options. The plugin is stable for Babel 6, but users should note that modern Babel (v7+) recommends @babel/plugin-proposal-object-rest-spread or the preset-env's built-in support. Release cadence is low since it focuses on a specific transform.

npm install babel-plugin-object-rest-spread
INSTALL
IMPORT
SIG · BABEL-PLUGIN-OBJEC
B
babel-plugin-object-rest-spread
devopsjavascriptv0.0.0
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.

plugin
plugins: ['babel-plugin-object-rest-spread']
plugins: ['object-rest-spread']
Babel 6 expects the full package name; avoid abbreviating.
options
plugins: [['babel-plugin-object-rest-spread', { loose: true }]]
plugins: ['babel-plugin-object-rest-spread', { loose: true }]
Options must be in an array with the plugin name; this syntax changed from Babel 5.
require
require('babel-plugin-object-rest-spread')
require('babel-plugin-object-rest-spread').default
The plugin is CommonJS-compatible; no .default needed.

Demonstrates transforming object rest/spread with .babelrc config and sample output.

// Install: npm install --save-dev babel-plugin-object-rest-spread // .babelrc { "plugins": ["babel-plugin-object-rest-spread"] } // Input: uses object rest/spread const { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; const n = { x, y, ...z }; // Output (with loose:false by default) var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var ref = { x: 1, y: 2, a: 3, b: 4 }; var x = ref.x; var y = ref.y; var z = _objectWithoutProperties(ref, ['x', 'y']); var n = _extends({ x: x, y: y }, z);
Debug
Known issues
deprecatedThis plugin is for Babel 6 only. For Babel 7+, use @babel/plugin-proposal-object-rest-spread or include in @babel/preset-env.
fix
Upgrade to @babel/plugin-proposal-object-rest-spread (v7) or use @babel/preset-env.
affects: >=0.0.0
breakingOptions 'useBuiltIns' was removed in favor of 'loose' and 'extends' options.
fix
Use { loose: true, extends: true } instead of useBuiltIns.
affects: <1.0.0 (if applicable)
gotchaPlugin does not include destructuring transform; if you need full destructuring support, you must add transform-es2015-destructuring separately.
fix
Add 'transform-es2015-destructuring' to your Babel plugins list.
affects: >=0.0.0
gotchaThe 'extends' option uses Object.assign if available; ensure your target environment supports it or use a polyfill.
fix
Add babel-plugin-transform-object-assign or include a Object.assign polyfill.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Requires Babel "^6.0.0-0", but was loaded with "7.x.x".
Using Babel 7 with a Babel 6 plugin.
fix
Use @babel/plugin-proposal-object-rest-spread or @babel/preset-env.
SyntaxError: Unexpected token '...'
Object rest/spread not transformed because plugin missing or not configured.
fix
Ensure babel-plugin-object-rest-spread is in your .babelrc plugins array.
ReferenceError: _objectWithoutProperties is not defined
Generated code uses helper that wasn't provided.
fix
Add 'babel-plugin-transform-runtime' or include 'babel-runtime' if using loose mode with extends:false.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies
babel-runtimeoptionalruntime helpers for extended object spread
Agent activity
6 hits · last 30 days
node
6
Resources
babel-plugin-object-rest-spread — npm install babel-plugin-object-rest-spread · libregistry