Babel
Babel is a compiler for writing next generation JavaScript.
Installation
npm install --save-dev @babel/core @babel/cli @babel/node
Configuration
package.json
{
"scripts": {
"start": "node index.js",
"start:dev": "babel-node index.js"
},
}
Run the script.
npm run start:dev
Presets
@babel/preset-env
A Babel preset for each environment.
npm install --save-dev @babel/preset-env
.babelrc.json
{
"presets" : ["@babel/preset-env"]
}
@babel/preset-react
Babel preset for all React plugins.
npm install --save-dev @babel/preset-react
.babelrc.json
{
"presets": ["@babel/preset-react"]
}
@babel/preset-typescript
Babel preset for TypeScript.
npm install --save-dev @babel/preset-typescript
.babelrc.json
{
"presets": ["@babel/preset-typescript"]
}
Dependencies
@babel/core
Babel compiler core.
npm install --save-dev @babel/core
@babel/cli
Babel command line.
npm install --save-dev @babel/cli
@babel/node
Babel command line.
npm install --save-dev @babel/node