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 = [{
// by the client.
name: 'boot',
entry: './src/boot/index',
transforms: ['babel'],
},{
// The sidebar application for displaying and editing annotations.
name: 'app',
transforms: ['coffee'],
transforms: ['babel', 'coffee'],
entry: './src/sidebar/app',
},{
// The annotation layer which handles displaying highlights, presenting
// annotation tools on the page and instantiating the sidebar application.
name: 'injector',
entry: './src/annotator/main',
transforms: ['coffee'],
transforms: ['babel', 'coffee'],
}];
var appBundleConfigs = appBundles.map(function (config) {
......
......@@ -17,7 +17,8 @@
"angulartics": "0.17.2",
"autofill-event": "0.0.1",
"autoprefixer": "^6.0.3",
"babelify": "^6.1.3",
"babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"browserify-ngannotate": "^1.0.1",
......@@ -36,7 +37,7 @@
"dom-anchor-fragment": "^1.0.1",
"dom-anchor-text-position": "^4.0.0",
"dom-anchor-text-quote": "^4.0.2",
"dom-seek": "^1.0.1",
"dom-seek": "^4.0.3",
"end-of-stream": "^1.1.0",
"escape-html": "^1.0.3",
"escape-string-regexp": "^1.0.5",
......@@ -122,6 +123,7 @@
]
},
"browser": {
"dom-anchor-fragment": "./node_modules/dom-anchor-fragment/dist/FragmentAnchor.js",
"hammerjs": "./node_modules/hammerjs/hammer.js",
"jquery": "./node_modules/jquery/dist/jquery.slim.js"
},
......
......@@ -6,6 +6,7 @@
var fs = require('fs');
var path = require('path');
var babelify = require('babelify');
var browserify = require('browserify');
var coffeeify = require('coffeeify');
var exorcist = require('exorcist');
......@@ -163,6 +164,9 @@ module.exports = function createBundle(config, buildOpts) {
if (transform === 'coffee') {
bundle.transform(coffeeify);
}
if (transform === 'babel') {
bundle.transform(babelify);
}
});
if (config.minify) {
......
......@@ -79,6 +79,7 @@ module.exports = function(config) {
// https://github.com/karma-runner/karma-coverage/issues/157
instrumenter: require('isparta'),
}),
'babelify',
],
},
......
......@@ -2,7 +2,7 @@
var SearchClient = require('../search-client');
function await(emitter, event) {
function awaitEvent(emitter, event) {
return new Promise(function (resolve) {
emitter.on(event, resolve);
});
......@@ -33,7 +33,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub();
client.on('results', onResults);
client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () {
return awaitEvent(client, 'end').then(function () {
assert.calledWith(onResults, RESULTS);
});
});
......@@ -43,7 +43,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub();
client.on('results', onResults);
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(2,4));
});
......@@ -67,7 +67,7 @@ describe('SearchClient', function () {
client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () {
return awaitEvent(client, 'end').then(function () {
assert.calledWith(onResults, []);
assert.calledOnce(fakeSearchFn);
});
......@@ -79,7 +79,7 @@ describe('SearchClient', function () {
var onResults = sinon.stub();
client.on('results', onResults);
client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () {
return awaitEvent(client, 'end').then(function () {
assert.calledOnce(onResults);
assert.calledWith(onResults, RESULTS);
});
......@@ -108,7 +108,7 @@ describe('SearchClient', function () {
var onError = sinon.stub();
client.on('error', onError);
client.get({uri: 'http://example.com'});
return await(client, 'end').then(function () {
return awaitEvent(client, 'end').then(function () {
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