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.
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.
@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.
Babel is a JavaScript compiler which is used by framework to make code understandable for older browser.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With