Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@babel/plugin-proposal-class-properties vs babel-plugin-transform-class-properties

Tags:

babeljs

what is the difference between these 2 babel plugins?

  • @babel/plugin-proposal-class-properties

  • babel-plugin-transform-class-properties.

Which one should I use?

After looking here and here it's still not clear to me.

like image 790
Tenbrink Avatar asked Sep 25 '18 15:09

Tenbrink


People also ask

What is Babel plugin transform class properties?

According to the documentation, this plugin will transform class properties in such a way that you can define class properties using property initializer syntax (ie. by using the = assignment operator). In JavaScript, current class syntax only allows for you to define methods inside of a class, nothing else.

What is Babel plugin proposal class properties?

@babel/plugin-proposal-class-properties:This plugin transforms class properties in such a way that we can define class properties using property initializer syntax (i.e., by using the = assignment operator). In the previous versions of Babel, the class syntax only allows us to define methods inside a class.

What is Babel plugin transform classes?

Babel is a JavaScript compiler which is used by framework to make code understandable for older browser.

What is Babel transform?

babel.transform(code: string, options?: Object, callback: Function) Transforms the passed in code . Calling a callback with an object with the generated code, source map, and AST.


1 Answers

I think you should use @babel/plugin-proposal-class-properties because it is following current naming convention.

Renames: -proposal-
Any proposals will be named with -proposal- now to signify that they aren't officially in JavaScript yet.
So @babel/plugin-transform-class-properties becomes @babel/plugin-proposal-class-properties, and we would name it back once it gets into Stage 4.

from We’re nearing the 7.0 Babel release. Here’s all the cool stuff we’ve been doing.

like image 120
Aurelijus Rozenas Avatar answered Sep 29 '22 00:09

Aurelijus Rozenas