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

babel-plugin-syntax-object-rest-spread

JSON →
library6.13.0jsnpmunverified

A Babel plugin that allows parsing of object rest/spread syntax (e.g., `const { a, ...rest } = obj;` or `const clone = { ...obj }`) in JavaScript. Current version is 6.13.0, part of the Babel 6 ecosystem. This plugin only enables parsing; transformation requires a separate plugin like `babel-plugin-transform-object-rest-spread`. It is syntax-only and does not include any runtime polyfills. Use with Babel 6; for Babel 7+, use `@babel/plugin-syntax-object-rest-spread`.

npm install babel-plugin-syntax-object-rest-spread
INSTALL
IMPORT
SIG · BABEL-PLUGIN-SYNTA
B
babel-plugin-syntax-object-rest-spread
devopsjavascriptv6.13.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 in .babelrc
{ "plugins": ["syntax-object-rest-spread"] }
{ "plugins": ["babel-plugin-syntax-object-rest-spread"] }
Plugin name in .babelrc is the short name; the full npm package name is only used for installation.
Node API require
require("babel-core").transform(code, { plugins: ["syntax-object-rest-spread"] });
require("babel-plugin-syntax-object-rest-spread").default;
The plugin is used as a string in the plugins array, not required directly.
CLI usage
babel --plugins syntax-object-rest-spread script.js
babel --plugins babel-plugin-syntax-object-rest-spread script.js
CLI also uses the short name without the 'babel-plugin-' prefix.

Shows installation, .babelrc config, and a code snippet that requires this plugin for parsing.

// Install the plugin // npm install babel-plugin-syntax-object-rest-spread // .babelrc { "plugins": ["syntax-object-rest-spread"] } // Source code that uses object rest/spread const { a, ...rest } = { a: 1, b: 2, c: 3 }; const clone = { ...rest, d: 4 }; console.log(a, rest, clone);
Debug
Known issues
deprecatedbabel-plugin-syntax-object-rest-spread is deprecated. Use @babel/plugin-syntax-object-rest-spread for Babel 7.
fix
For Babel 7, install @babel/plugin-syntax-object-rest-spread and update .babelrc to use '@babel/plugin-syntax-object-rest-spread'.
affects: >=6.0.0
gotchaThis plugin only enables parsing, not transformation. Without a transform plugin, object rest/spread will not be compiled to older syntax.
fix
Add a transform plugin like babel-plugin-transform-object-rest-spread or use babel-preset-env with the appropriate targets.
affects: >=6.0.0
gotchaUsing the full npm package name in .babelrc or CLI will not work; it requires the short name 'syntax-object-rest-spread'.
fix
Use 'syntax-object-rest-spread' instead of 'babel-plugin-syntax-object-rest-spread' in configuration.
affects: >=6.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token ...
Object rest/spread syntax is not natively supported without the plugin.
fix
Install babel-plugin-syntax-object-rest-spread and add it to your .babelrc plugins.
Error: Requires Babel "^6.0.0-0", but was loaded with "7.x.y"
This plugin is for Babel 6, but you're using Babel 7.
fix
Use @babel/plugin-syntax-object-rest-spread instead.
Module not found: Can't resolve 'babel-plugin-syntax-object-rest-spread'
The package is not installed.
fix
Run npm install babel-plugin-syntax-object-rest-spread --save-dev.
Upgrade
Version history
6.13.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
babel-plugin-syntax-object-rest-spread — npm install babel-plugin-syntax-object-rest-spread · libregistry