visit
Class fields or class properties.
A quite useful feature, isn't it? But the problem is that Webpack doesn't know how to deal with it. Let's look at the example.Use
npm install -D babel-loader @babel/core @babel/preset-env webpack
.After the installation process, you need to add this piece of code into you
rules
section of a webpack.config.js
file.
{
test: /\.m?js$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env',
{
plugins: ['@babel/plugin-proposal-class-properties'],
},
],
},
}
npm install eslint babel-eslint --save-dev
module.exports = {
parser: "babel-eslint",
};
into your .eslintrc.js file.
That's it! If I knew it before it could have saved a lot of time for me. I hope you found this guide useful. If you have any questions, please let me know in the comments below!