diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000000..f2b31b5064 --- /dev/null +++ b/.babelrc @@ -0,0 +1,8 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "transform-object-rest-spread" + ] +} diff --git a/Gruntfile.js b/Gruntfile.js index 0ca95cbc99..0066e0851c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,6 +10,7 @@ module.exports = function (grunt) { }); } + grunt.loadNpmTasks("grunt-browserify"); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-connect'); @@ -25,6 +26,20 @@ module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), clean: ['dist', 'tmp'], + babelify: { + dist: { + options: { + transform: [ + ["babelify"] + ] + }, + files: { + "./dist/axe.js": [ + "./dist/axe.js" + ] + } + } + }, concat: { engine: { src: [ @@ -265,9 +280,9 @@ module.exports = function (grunt) { grunt.registerTask('default', ['build']); grunt.registerTask('build', ['clean', 'validate', 'concat:commons', 'configure', - 'concat:engine', 'copy', 'uglify']); + 'concat:engine', 'copy', 'browserify', 'uglify']); - grunt.registerTask('test', ['build', 'testconfig', 'fixture', 'connect', + grunt.registerTask('test', ['build', 'testconfig', 'fixture', 'connect', 'mocha', 'jshint']); grunt.registerTask('test-ci', ['build', 'fixture', 'connect', 'continue:on', 'saucelabs-mocha', diff --git a/lib/intro.stub b/lib/intro.stub index 5c1d324773..a2653d3023 100644 --- a/lib/intro.stub +++ b/lib/intro.stub @@ -9,4 +9,6 @@ * distribute or in any file that contains substantial portions of this source * code. */ -(function (global) { +(function () { + // A window reference is required to access the axe object in a "global". + var global = window; diff --git a/lib/outro.stub b/lib/outro.stub index faef449b9d..53b27402c7 100644 --- a/lib/outro.stub +++ b/lib/outro.stub @@ -1,3 +1,3 @@ axe.version = '<%= pkg.version %>'; -}(this)); +}()); diff --git a/package.json b/package.json index e0f94d028f..e73ff069f2 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,17 @@ "test": "grunt test" }, "devDependencies": { + "babel-plugin-transform-object-rest-spread": "^6.6.5", + "babel-polyfill": "^6.7.4", + "babel-preset-es2015": "^6.6.0", + "babelify": "^7.2.0", "blanket": "~1.1.7", "chai": "~3.0.0", "clone": "~1.0.2", "dot": "~1.0.3", "grunt": "~0.4.5", "grunt-blanket-mocha": "~0.5.0", + "grunt-browserify": "^5.0.0", "grunt-continue": "^0.1.0", "grunt-contrib-clean": "~0.6.0", "grunt-contrib-concat": "~0.5.1",