Commit 0306b229 authored by Sean Roberts's avatar Sean Roberts Committed by GitHub

Merge pull request #421 from hypothesis/enable-es6

Enable ES2015 transpilation in the client
parents efcc4582 18343b7f
{
"presets": ["es2015"],
"ignore": "**/vendor/*"
}
...@@ -102,17 +102,18 @@ var appBundles = [{ ...@@ -102,17 +102,18 @@ var appBundles = [{
// by the client. // by the client.
name: 'boot', name: 'boot',
entry: './src/boot/index', entry: './src/boot/index',
transforms: ['babel'],
},{ },{
// The sidebar application for displaying and editing annotations. // The sidebar application for displaying and editing annotations.
name: 'app', name: 'app',
transforms: ['coffee'], transforms: ['babel', 'coffee'],
entry: './src/sidebar/app', entry: './src/sidebar/app',
},{ },{
// The annotation layer which handles displaying highlights, presenting // The annotation layer which handles displaying highlights, presenting
// annotation tools on the page and instantiating the sidebar application. // annotation tools on the page and instantiating the sidebar application.
name: 'injector', name: 'injector',
entry: './src/annotator/main', entry: './src/annotator/main',
transforms: ['coffee'], transforms: ['babel', 'coffee'],
}]; }];
var appBundleConfigs = appBundles.map(function (config) { var appBundleConfigs = appBundles.map(function (config) {
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
"angulartics": "0.17.2", "angulartics": "0.17.2",
"autofill-event": "0.0.1", "autofill-event": "0.0.1",
"autoprefixer": "^6.0.3", "autoprefixer": "^6.0.3",
"babelify": "^6.1.3", "babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"browserify": "^13.0.0", "browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0", "browserify-istanbul": "^2.0.0",
"browserify-ngannotate": "^1.0.1", "browserify-ngannotate": "^1.0.1",
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
"dom-anchor-fragment": "^1.0.1", "dom-anchor-fragment": "^1.0.1",
"dom-anchor-text-position": "^4.0.0", "dom-anchor-text-position": "^4.0.0",
"dom-anchor-text-quote": "^4.0.2", "dom-anchor-text-quote": "^4.0.2",
"dom-seek": "^1.0.1", "dom-seek": "^4.0.3",
"end-of-stream": "^1.1.0", "end-of-stream": "^1.1.0",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",
...@@ -122,6 +123,7 @@ ...@@ -122,6 +123,7 @@
] ]
}, },
"browser": { "browser": {
"dom-anchor-fragment": "./node_modules/dom-anchor-fragment/dist/FragmentAnchor.js",
"hammerjs": "./node_modules/hammerjs/hammer.js", "hammerjs": "./node_modules/hammerjs/hammer.js",
"jquery": "./node_modules/jquery/dist/jquery.slim.js" "jquery": "./node_modules/jquery/dist/jquery.slim.js"
}, },
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var babelify = require('babelify');
var browserify = require('browserify'); var browserify = require('browserify');
var coffeeify = require('coffeeify'); var coffeeify = require('coffeeify');
var exorcist = require('exorcist'); var exorcist = require('exorcist');
...@@ -163,6 +164,9 @@ module.exports = function createBundle(config, buildOpts) { ...@@ -163,6 +164,9 @@ module.exports = function createBundle(config, buildOpts) {
if (transform === 'coffee') { if (transform === 'coffee') {
bundle.transform(coffeeify); bundle.transform(coffeeify);
} }
if (transform === 'babel') {
bundle.transform(babelify);
}
}); });
if (config.minify) { if (config.minify) {
......
...@@ -79,6 +79,7 @@ module.exports = function(config) { ...@@ -79,6 +79,7 @@ module.exports = function(config) {
// https://github.com/karma-runner/karma-coverage/issues/157 // https://github.com/karma-runner/karma-coverage/issues/157
instrumenter: require('isparta'), instrumenter: require('isparta'),
}), }),
'babelify',
], ],
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
var SearchClient = require('../search-client'); var SearchClient = require('../search-client');
function await(emitter, event) { function awaitEvent(emitter, event) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
emitter.on(event, resolve); emitter.on(event, resolve);
}); });
...@@ -33,7 +33,7 @@ describe('SearchClient', function () { ...@@ -33,7 +33,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub(); var onResults = sinon.stub();
client.on('results', onResults); client.on('results', onResults);
client.get({uri: 'http://example.com'}); client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () { return awaitEvent(client, 'end').then(function () {
assert.calledWith(onResults, RESULTS); assert.calledWith(onResults, RESULTS);
}); });
}); });
...@@ -43,7 +43,7 @@ describe('SearchClient', function () { ...@@ -43,7 +43,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub(); var onResults = sinon.stub();
client.on('results', onResults); client.on('results', onResults);
client.get({uri: 'http://example.com'}); client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () { return awaitEvent(client, 'end').then(function () {
assert.calledWith(onResults, RESULTS.slice(0,2)); assert.calledWith(onResults, RESULTS.slice(0,2));
assert.calledWith(onResults, RESULTS.slice(2,4)); assert.calledWith(onResults, RESULTS.slice(2,4));
}); });
...@@ -67,7 +67,7 @@ describe('SearchClient', function () { ...@@ -67,7 +67,7 @@ describe('SearchClient', function () {
client.get({uri: 'http://example.com'}); client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () { return awaitEvent(client, 'end').then(function () {
assert.calledWith(onResults, []); assert.calledWith(onResults, []);
assert.calledOnce(fakeSearchFn); assert.calledOnce(fakeSearchFn);
}); });
...@@ -79,7 +79,7 @@ describe('SearchClient', function () { ...@@ -79,7 +79,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub(); var onResults = sinon.stub();
client.on('results', onResults); client.on('results', onResults);
client.get({uri: 'http://example.com'}); client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () { return awaitEvent(client, 'end').then(function () {
assert.calledOnce(onResults); assert.calledOnce(onResults);
assert.calledWith(onResults, RESULTS); assert.calledWith(onResults, RESULTS);
}); });
...@@ -108,7 +108,7 @@ describe('SearchClient', function () { ...@@ -108,7 +108,7 @@ describe('SearchClient', function () {
var onError = sinon.stub(); var onError = sinon.stub();
client.on('error', onError); client.on('error', onError);
client.get({uri: 'http://example.com'}); client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () { return awaitEvent(client, 'end').then(function () {
assert.calledWith(onError, err); assert.calledWith(onError, err);
}); });
}); });
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment