What is Sucrase?
Sucrase let us develop Node app in ES6,is an alternative to Babel that allows super-fast development builds. If it fits your use case, hopefully, Sucrase can speed up your development experience!
What is 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.
Getting Start
First you need to install the packages as development dependencies,
yarn add --dev sucrase
yarn add --dev nodemon
# Or
npm install --save-dev sucrase
npm install --save-dev nodemon
After setting the packages as project dependencies, if we try to use the features of Sucrase like this:
node index.js
#Or
nodemon index.js
You will encounter an error because to compile with sucrase, is necessary use sucrase-node instead node, on use nodemon node is called every time some file change in a directory, so how we set to nodemon use sucrase-node instead node?
Nodemon + Sucrase
To set Nodemon to use sucrase we need to create a file nodemon.json in our '/' project, with the following code:
{
"execMap":{
"js": "node -r sucrase/register"
}
}
Once we create this file every time nodemon executes a js file, it will be compiled by sucrase before run the code.
Top comments (0)