What is @babel/plugin-syntax-object-rest-spread?
The @babel/plugin-syntax-object-rest-spread package allows Babel to parse and handle the object rest/spread syntax. This syntax enables the extraction of properties from objects and the creation of new objects with certain properties of an existing object. It is important to note that this plugin only enables the syntax and does not transform it; the actual transformation is handled by another plugin like @babel/plugin-proposal-object-rest-spread.
What are @babel/plugin-syntax-object-rest-spread's main functionalities?
Object Rest Properties
Allows extracting the remaining own enumerable property keys that are not already picked off by the destructuring pattern.
{ ...rest } = object
Object Spread Properties
Enables the creation of a new object by copying own enumerable properties from a provided object onto the new object.
{ ...object }
Other packages similar to @babel/plugin-syntax-object-rest-spread
@babel/plugin-proposal-object-rest-spread
This package not only allows Babel to parse the object rest/spread syntax but also transforms it. It is the complement to @babel/plugin-syntax-object-rest-spread, which only enables the syntax.
babel-plugin-transform-object-rest-spread
This is a legacy plugin that was used before the proposal reached stage 4 and was included in the official ECMAScript standard. It both enabled the syntax and transformed it, similar to @babel/plugin-proposal-object-rest-spread.
@babel/plugin-syntax-object-rest-spread
Allow parsing of object rest/spread
See our website @babel/plugin-syntax-object-rest-spread for more information.
Install
Using npm:
npm install --save-dev @babel/plugin-syntax-object-rest-spread
or using yarn:
yarn add @babel/plugin-syntax-object-rest-spread --dev