Posts

Showing posts from February, 2024

Support for the experimental syntax 'decorators' isn't currently enabled (5:3):

This guide is targeted specifically to people who encountered this error while using MobX with ReactJS Error Now I know, its frustrating when you got this error, no worries, I know exactly what caused the error. Here was my code that caused the error: // store.js import { observable , action } from 'mobx' ; class ProductStore {   @ observable products = [];   @ action   addProduct ( product ) {     this . products . push ( product );   } } const store = new ProductStore (); export default store ; Solutions tried You might see this message in your console: "Add @babel/plugin-proposal-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators) to the 'plugins' section of your Babel config to enable transformation." and you might have added this new dependencies in both .babelrc [source] , babel.config.json [source] , installing the dependencies in dev using npm [source] , installing it as regular dependency [s...

The decorators plugin, when .version is '2018-09' or not specified, requires a 'decoratorsBeforeExport' option, whose value must be a boolean.

 There are solution such as this , but it just couldn't work for me. Then I came across this . It made me wonder, what if the problem lies within the webpack.config.js. So, I went on and modified my webpack.config.js, and voila, it actually worked.  Here was my original webpack.config.js configuration: // webpack.config.js module . exports = {     module : {       rules : [         {           test : / \. js $ / ,           exclude : /node_modules/ ,           use : {             loader : 'babel-loader' ,           },         },       ],     },   };   I removed this syntax:           use : {             loader : 'babel-loader' ,           }, and it worked! A...

What is .babelrc used for?

Note: I am no expert and I am just stating what I know and read online .babelrc is the configuration file used for your babel What is babel used for? Babel is used to make sure the javascript in your website are all backward compatible. So older engine of javascript can be used to access your website, as well as modern javascript. What is the difference between babel and package.json ? Babel is considered a library, while package.json is a file that describes the meta data of a project, as well as defining the functional attributes that include the dependencies included and scripts to be ran (for building the dev and production environment). You can use Babel by including Babel dependencies into package.json Where should I create the .babelrc file? 1) .babelrc file can be created anywhere, preferrably within the same directory of package.json.  2) You can use babel by specifying the `"babel": {}` within the package.json as well. [source]   3)  If .babelrc file is not fou...