Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel plugin: what's the difference between "transform-object-rest-spread" and "syntax-object-rest-spread"

there are not so much detail in the documentation about these two plugins, I know both of them make syntax like {...obj} works.

But how do I decide which plugin to use ?

like image 396
Littlee Avatar asked May 30 '26 05:05

Littlee


1 Answers

We have the docs on this here: https://babeljs.io/docs/en/plugins#syntax-plugins

-syntax- plugins only enable the syntax to parse correctly and don't transform the code at all. You normally wouldn't need to specify this unless it's simply for it to parse correctly.

-transform- plugins enable the syntax and also transform the code for you.

You want to use babel-plugin-transform-object-rest-spread if you are using Babel v6.

like image 63
hzoo Avatar answered Jun 01 '26 10:06

hzoo