We’re ready to transpile our code! In the last exercise, we wrote the following script in package.json:
"build": "babel src -d lib"
Now, we need to call
"build" from the command line to transpile and write ES5 code to a directory called
From the command line, we type:
npm run build
The command above runs the
build script in package.json.
Babel writes the ES5 code to a file named main.js (it’s always the same name as the original file), inside of a folder called
lib. The resulting directory structure is:
project |_ lib |___ main.js |_ node_modules |___ .bin |___ ... |_ src |___ main.js |_ .babelrc |_ package.json
Notice, the directory contains a new folder named lib, with one file, called main.js.
npm run build) to transpile all of your code.
Transpile the ES6+ code to
lib using the
Once you’ve done this, navigate to the new lib folder and open main.js.