Step 1: check your Node.js version:
$ node -vv12.0.0
Hegel was developed for current LTS version of Node.js (12.16.1). So, you need to have at least 12 version.
If you have less than 12 version of Node.js you may change it to 12 or latest by nvm
.
Step 2: install @hegel/cli
with npm globally or locally:
# globally$ npm install -g @hegel/cli# locally$ npm install -D @hegel/cli
Finally. You already can use it into your JavaScript project:
# globally$ hegelNo errors!# locally$ npx hegelNo errors!
Hegel has a zero-configuration, but if you want to change settings see Configuration Section.
Setup Project
Also you need to setup a compiler which will strip away Hegel types. The same as Flow, you can choose between Babel and flow-remove-types.
Babel
$ npm i -D @babel/core @babel/cli @babel/preset-flow
After that you need to create a .babelrc file at the root of your project with next content:
{"presets": [["@babel/preset-flow", { "all": true }]]}
Now you can run it manualy:
$ npx babel directory_with_your_project_files/ -- -d compilation_destination_directory
Or you can add script inside your package.json
scripts
section:
{"scripts": {"build": "babel directory_with_your_project_files/ -d compilation_destination_directory/"}}
Flow Remove Types
Install flow-remove-types
:
$ npm i -D flow-remove-types
And add next script inside your package.json
scripts
section:
{"scripts": {"build": "flow-remove-types directory_with_your_project_files/ --out-dir compilation_destination_directory/ --all"}}
And run it by:
$ npm run build