Enable ES6 support by using babelify transform in browserify build

* Add babelify as dev dependency
* Add babelify transform to browserify build
* Enable es6 support for jshint
* Ignore minified js files in babel transform
This commit is contained in:
Tankred Hase 2016-01-21 17:37:22 +07:00
parent d725abd5b6
commit 01b0cd8387
3 changed files with 22 additions and 11 deletions

View File

@ -11,6 +11,7 @@
"expr": true,
"undef": true,
"unused": true,
"esnext": true,
"globals": {
"console": true,

View File

@ -45,7 +45,13 @@ module.exports = function(grunt) {
browserifyOptions: {
standalone: 'openpgp'
},
external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch' ]
external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch' ],
transform: [
["babelify", {
ignore: ['*.min.js'],
presets: ["es2015"]
}]
]
}
},
openpgp_debug: {
@ -57,7 +63,13 @@ module.exports = function(grunt) {
debug: true,
standalone: 'openpgp'
},
external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch' ]
external: [ 'crypto', 'buffer', 'node-localstorage', 'node-fetch' ],
transform: [
["babelify", {
ignore: ['*.min.js'],
presets: ["es2015"]
}]
]
}
},
worker: {
@ -139,8 +151,8 @@ module.exports = function(grunt) {
build: ['Gruntfile.js'],
options: {
config: ".jscsrc",
esnext: false, // If you use ES6 http://jscs.info/overview.html#esnext
verbose: true, // If you need output with rule names http://jscs.info/overview.html#verbose
esnext: true,
verbose: true,
}
},
jsdoc: {
@ -260,16 +272,12 @@ module.exports = function(grunt) {
fs.writeFileSync(path, JSON.stringify(file, null, 2) + '\n');
}
grunt.registerTask('default', 'Build OpenPGP.js', function() {
grunt.task.run(['clean', 'copy:zlib', 'browserify', 'replace', 'uglify']);
//TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun
grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.');
});
// Build tasks
grunt.registerTask('default', ['clean', 'copy:zlib', 'browserify', 'replace', 'uglify']);
grunt.registerTask('documentation', ['jsdoc']);
// Test/Dev tasks
grunt.registerTask('test', ['jshint', 'jscs', 'copy:zlib', 'mochaTest']);
grunt.registerTask('coverage', ['copy:zlib', 'mocha_istanbul:coverage']);
grunt.registerTask('saucelabs', ['default', 'copy:browsertest', 'connect', 'saucelabs-mocha']);
};

View File

@ -33,6 +33,8 @@
},
"devDependencies": {
"asmcrypto-lite": "^1.0.0",
"babel-preset-es2015": "^6.3.13",
"babelify": "^7.2.0",
"chai": "~3.4.1",
"es6-promise": "^1.0.0",
"grunt": "~0.4.5",