compiler
A compiler is a special program that translates a programming language's source code into machine code, bytecode or another programming language. The source code is typically written in a high-level, human-readable language such as Java or C++. A
// Babel Input: ES2015 arrow function
[1, 2, 3].map(n => n + 1);
// Babel Output: ES5 equivalent
[1, 2, 3].map(function(n) {
return n + 1;
});
1. Installation
npm install --save-dev @babel/core
2. Usage
{
"scripts": {
"dev": "babel-node src/server.js"
}
}
3. Create babel.config.json configuration file
npm install @babel/preset-env --save-dev
{
"presets": ["@babel/preset-env"]
}
nodemon을 사용해야 하는 이유는?
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.
1. Installation
npm install --save-dev nodemon
npm install @babel/core @babel/node --save-dev
2. Usage
{
"scripts": {
"dev": "nodemon --exec babel-node src/server.js"
}
}
3. Create babel.config.json configuration file
npm install @babel/preset-env --save-dev
{
"presets": ["@babel/preset-env"]
}
Config files을 이용하여 nodemon사용하기
nodemon supports local and global configuration files. These are usually named nodemon.json and can be located in the current working directory or in your home directory.
{
"ignore": ["src/public/*"],
"exec": "babel-node src/server.js"
}
{
"scripts": {
"dev": "nodemon"
}
}
https://babeljs.io/docs/en/#babel-is-a-javascript-compiler
https://babeljs.io/setup#installation
https://www.npmjs.com/package/nodemon