babeljsbabel-plugin

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 ?


Solution

  • 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.