From cbb06a48e28c594a53f61e49857cbb711bd74ce9 Mon Sep 17 00:00:00 2001 From: Carson Bruce Date: Wed, 17 Jun 2015 09:58:45 +1200 Subject: [PATCH] feat(app): additional app generator option for ES6 preprocessing using babel Building on from the ES6 client preprocessor have added karma config and related karma-babel-preprocessor module for ES6 client tests for complete ES6 client support Related issue: Any plans for es6 and traceur support? #684 --- app/templates/_package.json | 1 + app/templates/karma.conf.js | 17 ++++++++++++++++- test/fixtures/bower.json | 1 - test/fixtures/package.json | 4 +++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/templates/_package.json b/app/templates/_package.json index 5d0592941..fc374be27 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -46,6 +46,7 @@ "grunt-contrib-coffee": "^0.10.1",<% } %><% if(filters.jade) { %> "grunt-contrib-jade": "^0.11.0",<% } %><% if(filters.less) { %> "grunt-contrib-less": "^0.11.0",<% } %><% if(filters.babel) { %> + "karma-babel-preprocessor": "^5.2.1", "grunt-babel": "~5.0.0",<% } %> "grunt-google-cdn": "~0.4.0", "grunt-newer": "~0.7.0", diff --git a/app/templates/karma.conf.js b/app/templates/karma.conf.js index 57b3fa6f2..e7307a90a 100644 --- a/app/templates/karma.conf.js +++ b/app/templates/karma.conf.js @@ -36,7 +36,8 @@ module.exports = function(config) { preprocessors: { '**/*.jade': 'ng-jade2js', - '**/*.html': 'html2js', + '**/*.html': 'html2js',<% if(filters.babel) { %> + 'client/app/**/*.js': 'babel',<% } %> '**/*.coffee': 'coffee', }, @@ -48,6 +49,20 @@ module.exports = function(config) { stripPrefix: 'client/' }, + <% if(filters.babel) { %> + babelPreprocessor: { + options: { + sourceMap: 'inline' + }, + filename: function (file) { + return file.originalPath.replace(/\.js$/, '.es5.js'); + }, + sourceFileName: function (file) { + return file.originalPath; + } + }, + <% } %> + // list of files / patterns to exclude exclude: [], diff --git a/test/fixtures/bower.json b/test/fixtures/bower.json index 7d9aae354..10dff6513 100644 --- a/test/fixtures/bower.json +++ b/test/fixtures/bower.json @@ -5,7 +5,6 @@ "angular": ">=1.2.*", "json3": "~3.3.1", "es5-shim": "~3.0.1", - "jquery": "~1.11.0", "bootstrap-sass-official": "~3.1.1", "bootstrap": "~3.1.1", "angular-resource": ">=1.2.*", diff --git a/test/fixtures/package.json b/test/fixtures/package.json index 856e4fcc2..c110f7838 100644 --- a/test/fixtures/package.json +++ b/test/fixtures/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "main": "server/app.js", "dependencies": { - "express": "~4.0.0", + "express": "~4.9.0", "morgan": "~1.0.0", "body-parser": "~1.5.0", "method-override": "~1.0.0", @@ -46,6 +46,8 @@ "grunt-contrib-coffee": "^0.10.1", "grunt-contrib-jade": "^0.11.0", "grunt-contrib-less": "^0.11.0", + "karma-babel-preprocessor": "^5.2.1", + "grunt-babel": "~5.0.0", "grunt-google-cdn": "~0.4.0", "grunt-newer": "~0.7.0", "grunt-ng-annotate": "^0.2.3",