In this video, Emmanuel Henri installs the required dependencies to be able to use ES6 syntax in your code. Then he adds the .babelrc file with its presets.
- [Narrator] This course will use es6 syntax throughout and we want to be able to code our server without worrying about any syntax breaking our application. So babble is the tool we'll setup to help us work with es6 without any issues. Let's get to it. So the first thing I want you to do is open the terminal. So go to view, integrate it terminal. So I want to install another dependency before we get to babble because when we start our server, we want to make sure that whenever we change something in our code, it refreshes the application automatically.
And we don't have to restart our server. And we're going to use nodemon to do that. So let's go ahead and do npm I, and this will go in the regular dependency, so save nodemon, like so. So now that we have nodemon installed, we need to install a few dependencies for babble. So let's go ahead and do that, so install, I. And for this one, we're going to save them to the dev dependency.
So dash dash save dash dev. And we'll install the dependencies we need. So we need to have babble cli. We need to have babble preset. And I'll explain what these presets are in a second. Well, the first one is basically to support es6, so es2015. And then the second one is the one that I'll explain what it is in a second. So babble preset dash stage dash zero.
So while this is installing, let's go to our browser. And let's close these here, and let's go to babble.js.io. So then go to forward slash docs forward slash plugins, like so. And these are the presets that I explained here. So you have the base presets and then you have the stage.
So basically when you install stage zero, it includes all the recent changes to the language such as es2017 and all stages above, so up to four. So if you enter stage four, it means it is finished on the part of the library. So if you ever have any doubts about which stage to put on your presets, use zero and you'll be safe. So once we have the dependencies installed, so let's go back to vs code, it should all be done by now. So once the dependencies are installed, we need to create a file called babble rc.
So let's go ahead and create a new file under project. So it's called dat babble rc, like so. And then inside of that file we'll create an object, and inside of that object we'll have the presets that we need to load, so that will be inside of an array. And I need es2015 and then I need stage zero, like so.
Okay, so now save that file. So now we've got our dependencies ready to build our server with es6 syntax.
- Setting up a project and a server
- Setting up a database and schema
- Creating POST, GET, PUT, and DELETE endpoints
- Serving files