- Create a new project
yarn init
- Install Babel modules
yarn add @babel/cli @babel/core @babel/plugin-proposal-class-properties @babel/plugin-proposal-private-methods @babel/preset-env --dev
- Create a new file .babelrc
{
{
"presets": [
"@babel/preset-env"
],
"plugins": [
["@babel/plugin-proposal-class-properties"],
["@babel/plugin-proposal-private-methods"]
]
}
}
-
Create a main.js or index.js (I will use main.js)
-
Configure package.json to run Babel
"scripts": {
"build": "yarn babel main.js -o main-compiled.js"
// or
"build": "yarn babel main.js -w -o main-compiled.js"
}
- Run babel
yarn build