Here are the required steps:
Note: We will be using npm to install the necessary dependencies, so you may need to install npm if you don't already have it installed.
Create a package.json file with the necessary requirements. The version numbers may change over time, so feel free to update as new versions are released.
Run npm install
Grunt, the task runner requires some configuration in order to run the various tasks needed to watch and transpile code. Add the following Gruntfile.js
Sample ES6 files to transpile
I have added two example files that are also referenced in Gruntfile.js. Pay attention to the last line in both files as it sets up two different Angular providers that will be used to inject the generated services into our Angular sample controller.
I purposely defined both an Angular service and an Angular value in order to demonstrate two different ways to integrate the code in the controller. As you can tell the service provider (GreetingService) is instantiated for us by Angular, so there is no need to call new to create an instance. The value provider (PersonService) is different since it passes in the raw constructor instead of an instance. This means we have to “new-up” the service before using it.
The only thing you have to do now is type grunt on the command line to kick things off
Anyway, there you have it. Adding ES6 to Angular 1.x is pretty straight forward.