I tried to trans-pile below code in try it out tab of babeljs -
class aboutController{
constructor(ajaxService){
this.ajaxService = ajaxService;
this.printLog();
}
printLog(){
this.ajaxService.log();
}
static $inject = ["ajaxService"];
}
The static keyword got trans-piled to
{
key: "$inject",
value: ["ajaxService"],
enumerable: true
}
I then tried out grunt-babel task to automate the build. My gruntfile.js looks like this -
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
babel: {
options: {
sourceMap: true,
highlightCode: true
},
es6: {
files: [
{
expand: true,
src: ['components/**/*.es6'],
ext: '.js'
}
]
}
},
watch: {
scripts: {
files: ['components/**/*.es6'],
tasks:['babel']
}
}
});
require("load-grunt-tasks")(grunt);
grunt.registerTask("default", ["babel", "watch"]);
}
But now the static keyword is giving error, when I remove the static keyword, the build is passing. Any idea how to fix this. Is grunt-babel outdated?
Here is how my packahe.json looks like -
{
"name": "babeles6",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-babel": "^5.0.1",
"grunt-contrib-watch": "^0.6.1",
"load-grunt-tasks": "^3.2.0"
}
}