Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 398f8d0

Browse files
author
Chris Clark
committedMay 14, 2015
Set up babel transpiler
1 parent e66978f commit 398f8d0

17 files changed

+94
-75
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Ignore object files.
1919
*.o
20-
build/*.js
20+
build/
2121
tags
2222
bin/rippled
2323
Debug/*.*

‎.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
lib-cov
22
coverage.html
3+
src
4+
dist/bower

‎.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: node_js
22
node_js:
3-
- "0.10"
3+
- "0.12"
44
before_script:
55
- npm install -g eslint
6-
- curl 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc' > ./eslintrc
6+
- curl 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc' > ./eslintrc
77
- eslint --reset -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
88
script: MOCHA_REPORTER=tap npm test --coverage
99
after_success:

‎Gulpfile.js

+42-42
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
/* eslint-disable no-var, no-param-reassign */
2+
/* these eslint rules are disabled because gulp does not support babel yet */
13
'use strict';
4+
var _ = require('lodash');
25
var gulp = require('gulp');
36
var gutil = require('gulp-util');
47
var watch = require('gulp-watch');
@@ -15,20 +18,33 @@ var argv = require('yargs').argv;
1518

1619
var pkg = require('./package.json');
1720

18-
function logPluginError(error) {
19-
gutil.log(error.toString());
20-
}
21-
22-
gulp.task('build', function(callback) {
23-
webpack({
21+
function webpackConfig(extension, overrides) {
22+
overrides = overrides || {};
23+
var defaults = {
2424
cache: true,
2525
entry: './src/index.js',
2626
output: {
2727
library: 'ripple',
2828
path: './build/',
29-
filename: ['ripple-', '.js'].join(pkg.version)
29+
filename: ['ripple-', extension].join(pkg.version)
30+
},
31+
module: {
32+
loaders: [{
33+
test: /\.js$/,
34+
exclude: /node_modules/,
35+
loader: 'babel-loader?optional=runtime'
36+
}]
3037
}
31-
}, callback);
38+
};
39+
return _.assign({}, defaults, overrides);
40+
}
41+
42+
function logPluginError(error) {
43+
gutil.log(error.toString());
44+
}
45+
46+
gulp.task('build', function(callback) {
47+
webpack(webpackConfig('.js'), callback);
3248
});
3349

3450
gulp.task('build-min', ['build'], function() {
@@ -39,17 +55,8 @@ gulp.task('build-min', ['build'], function() {
3955
});
4056

4157
gulp.task('build-debug', function(callback) {
42-
webpack({
43-
cache: true,
44-
entry: './src/index.js',
45-
output: {
46-
library: 'ripple',
47-
path: './build/',
48-
filename: ['ripple-', '-debug.js'].join(pkg.version)
49-
},
50-
debug: true,
51-
devtool: 'eval'
52-
}, callback);
58+
var configOverrides = {debug: true, devtool: 'eval'};
59+
webpack(webpackConfig('-debug.js', configOverrides), callback);
5360
});
5461

5562
/**
@@ -64,51 +71,44 @@ function buildUseError(cons) {
6471
}
6572

6673
gulp.task('build-core', function(callback) {
67-
webpack({
68-
entry: [
69-
'./src/remote.js'
70-
],
71-
externals: [
72-
{
73-
'./transaction': buildUseError('Transaction'),
74-
'./orderbook': buildUseError('OrderBook'),
75-
'./account': buildUseError('Account'),
76-
'./serializedobject': buildUseError('SerializedObject')
77-
}
78-
],
79-
output: {
80-
library: 'ripple',
81-
path: './build/',
82-
filename: ['ripple-', '-core.js'].join(pkg.version)
83-
},
74+
var configOverrides = {
75+
cache: false,
76+
entry: './src/remote.js',
77+
externals: [{
78+
'./transaction': buildUseError('Transaction'),
79+
'./orderbook': buildUseError('OrderBook'),
80+
'./account': buildUseError('Account'),
81+
'./serializedobject': buildUseError('SerializedObject')
82+
}],
8483
plugins: [
8584
new webpack.optimize.UglifyJsPlugin()
8685
]
87-
}, callback);
86+
};
87+
webpack(webpackConfig('-core.js', configOverrides), callback);
8888
});
8989

9090
gulp.task('bower-build', ['build'], function() {
9191
return gulp.src(['./build/ripple-', '.js'].join(pkg.version))
9292
.pipe(rename('ripple.js'))
93-
.pipe(gulp.dest('./dist/'));
93+
.pipe(gulp.dest('./dist/bower'));
9494
});
9595

9696
gulp.task('bower-build-min', ['build-min'], function() {
9797
return gulp.src(['./build/ripple-', '-min.js'].join(pkg.version))
9898
.pipe(rename('ripple-min.js'))
99-
.pipe(gulp.dest('./dist/'));
99+
.pipe(gulp.dest('./dist/bower'));
100100
});
101101

102102
gulp.task('bower-build-debug', ['build-debug'], function() {
103103
return gulp.src(['./build/ripple-', '-debug.js'].join(pkg.version))
104104
.pipe(rename('ripple-debug.js'))
105-
.pipe(gulp.dest('./dist/'));
105+
.pipe(gulp.dest('./dist/bower'));
106106
});
107107

108108
gulp.task('bower-version', function() {
109-
gulp.src('./dist/bower.json')
109+
gulp.src('./dist/bower/bower.json')
110110
.pipe(bump({version: pkg.version}))
111-
.pipe(gulp.dest('./dist/'));
111+
.pipe(gulp.dest('./dist/bower'));
112112
});
113113

114114
gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug',

‎npm-shrinkwrap.json

+13-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
"version": "0.12.5-rc2",
44
"description": "A JavaScript API for interacting with Ripple in Node.js and the browser",
55
"files": [
6-
"src/js/*",
6+
"dist/npm/*",
77
"bin/*",
88
"build/*",
99
"test/*",
10-
"Makefile",
1110
"Gulpfile.js"
1211
],
13-
"main": "src/",
12+
"main": "dist/npm/",
1413
"directories": {
1514
"test": "test"
1615
},
1716
"dependencies": {
1817
"async": "~0.9.0",
18+
"babel-runtime": "^5.3.2",
1919
"bignumber.js": "^2.0.3",
2020
"extend": "~1.2.1",
2121
"lodash": "^3.1.0",
@@ -26,6 +26,9 @@
2626
},
2727
"devDependencies": {
2828
"assert-diff": "^1.0.1",
29+
"babel": "^5.3.3",
30+
"babel-core": "^5.3.2",
31+
"babel-loader": "^5.0.0",
2932
"coveralls": "~2.10.0",
3033
"eslint": "^0.18.0",
3134
"gulp": "~3.8.10",
@@ -48,10 +51,12 @@
4851
},
4952
"scripts": {
5053
"build": "gulp",
54+
"compile": "babel --optional runtime -d dist/npm/ src/",
55+
"prepublish": "npm run compile",
5156
"postinstall": "cd node_modules/sjcl; ./configure --with-all --compress=none; make",
5257
"test": "istanbul test _mocha",
5358
"coveralls": "cat ./coverage/lcov.info | coveralls",
54-
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/master/eslintrc'; fi; eslint --reset -c eslintrc src/*.js",
59+
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; fi; eslint --reset -c eslintrc src/*.js",
5560
"perf": "./scripts/perf_test.sh"
5661
},
5762
"repository": {

‎scripts/perf_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ then
88
mkdir -p "$DIR/cache"
99
curl -L "$URL" > "$DEST"
1010
fi
11-
time node "$DIR/verify_ledger_json.js" "$DEST"
11+
npm run compile && time node "$DIR/verify_ledger_json.js" "$DEST"

‎scripts/publish

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ echo "publish to npm"
1717
npm publish
1818
exit_on_error
1919

20-
rm -rf dist
20+
rm -rf dist/bower
2121
echo ""
2222
echo "publish to bower"
2323

24-
git clone git@github.com:ripple/bower-ripple.git dist
24+
git clone git@github.com:ripple/bower-ripple.git dist/bower
2525
gulp bower
2626
exit_on_error
2727

28-
cd dist
28+
cd dist/bower
2929
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
3030
echo "version: $version"
3131
git add ripple.js ripple-debug.js ripple-min.js bower.json
@@ -40,4 +40,4 @@ exit_on_error
4040
git push origin master
4141
git push --tags origin master
4242

43-
cd ..
43+
cd ..

‎scripts/publish_rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ echo "publish rc to npm"
1717
npm publish --tag beta
1818
exit_on_error
1919

20-
rm -rf dist
20+
rm -rf dist/bower
2121
echo ""
2222
echo "publish to bower"
2323

24-
git clone git@github.com:ripple/bower-ripple.git dist
24+
git clone git@github.com:ripple/bower-ripple.git dist/bower
2525
gulp bower
2626
exit_on_error
2727

28-
cd dist
28+
cd dist/bower
2929
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
3030
echo "version: $version"
3131
git add ripple.js ripple-debug.js ripple-min.js bower.json
@@ -40,4 +40,4 @@ exit_on_error
4040
git push origin master
4141
git push --tags origin master
4242

43-
cd ..
43+
cd ..

‎scripts/publish_to_bower

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
rm -rf dist
2-
git clone git@github.com:ripple/bower-ripple.git dist
1+
rm -rf dist/bower
2+
git clone git@github.com:ripple/bower-ripple.git dist/bower
33
gulp bower
4-
cd dist
4+
cd dist/bower
55
version=$(cat bower.json | grep -Eo '([0-9]\.?)+(-rc[0-9])?')
66
echo "version: $version"
77
git add ripple.js ripple-debug.js ripple-min.js bower.json
88
git commit -m "[TASK] add v$version"
99
git tag "v$version"
1010
git push origin master
1111
git push --tags origin master
12-
cd ..
12+
cd ..

‎scripts/verify_ledger_json.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
var fs = require('fs');
4-
var Amount = require('../src/js/ripple').Amount;
5-
var Ledger = require('../src/js/ripple/ledger').Ledger;
4+
var Amount = require('../dist/npm').Amount;
5+
var Ledger = require('../dist/npm/ledger').Ledger;
66

77
function parse_options(from, flags) {
88
var argv = from.slice(),

‎src/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Request.prototype.addStream = function(stream, values) {
542542
break;
543543
}
544544
} else if (arguments.length > 1) {
545-
for (arg in arguments) {
545+
for (var arg in arguments) {
546546
this.addStream(arguments[arg]);
547547
}
548548
return;

‎test/amount-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ describe('Amount', function() {
11501150
var demAmount = Amount.from_json('10/0158415500000000C1F76FF6ECB0BAC600000000/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11511151
assert.strictEqual(demAmount.to_text_full(), '10/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11521152
demAmount = demAmount.applyInterest(459990264);
1153-
assert.strictEqual(demAmount.to_text_full(), '9.294949401870435/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
1153+
assert.strictEqual(demAmount.to_text_full(), '9.294949401870436/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11541154

11551155
});
11561156
it('from_json apply interest XAU', function() {
@@ -1168,7 +1168,7 @@ describe('Amount', function() {
11681168
var demAmount = Amount.from_json('10/0158415500000000C1F76FF6ECB0BAC600000000/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11691169
assert.strictEqual(demAmount.to_human_full(), '10/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11701170
demAmount = demAmount.applyInterest(459990264);
1171-
assert.strictEqual(demAmount.to_human_full(), '9.294949401870435/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
1171+
assert.strictEqual(demAmount.to_human_full(), '9.294949401870436/XAU (-0.5%pa)/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh');
11721172

11731173
});
11741174
it('from_json apply interest XAU human', function() {

‎test/currency-test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ describe('Currency', function() {
272272
assert.equal(0.995, precision(cur.get_interest_at(new Date(timeUtil.fromRipple(443845330 + 31536000))), 14));
273273

274274
// After one demurrage period, 1/e should have occurred
275-
assert.equal(1/Math.E, cur.get_interest_at(443845330 + 6291418827.05));
275+
var epsilon = 1e-14;
276+
assert(Math.abs(
277+
1/Math.E - cur.get_interest_at(443845330 + 6291418827.05)) < epsilon);
276278

277279
// One year before start, it should be (roughly) 0.5% higher.
278280
assert.equal(1.005, precision(cur.get_interest_at(443845330 - 31536000), 4));

‎test/ledger-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var Ledger = require('ripple-lib').Ledger;
77
* @param ledger_index {Number}
88
* Expects a corresponding ledger dump in $repo/test/fixtures/ folder
99
*/
10-
create_ledger_test = function (ledger_index) {
10+
var create_ledger_test = function (ledger_index) {
1111
describe(String(ledger_index), function() {
1212

1313
var path = __dirname + '/fixtures/ledger-full-'+ledger_index+'.json';

‎test/mocha.opts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--reporter spec --timeout 10000 --slow 500
1+
--reporter spec --timeout 10000 --slow 500 --compilers js:babel/register

‎test/request-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ describe('Request', function() {
510510

511511
it('Timeout', function(done) {
512512
var server = makeServer('wss://localhost:5006');
513-
var successEmited = false;
513+
var successEmitted = false;
514514

515515
server._request = function(req) {
516516
assert(req instanceof Request);
@@ -542,7 +542,7 @@ describe('Request', function() {
542542

543543
it('Timeout - satisfied', function(done) {
544544
var server = makeServer('wss://localhost:5006');
545-
var successEmited = false;
545+
var successEmitted = false;
546546

547547
server._request = function(req) {
548548
assert(req instanceof Request);

0 commit comments

Comments
 (0)
Please sign in to comment.