Skip to content

Commit bafc7bd

Browse files
author
Zhen Li
authored
Merge pull request #162 from lutovich/1.1-babel-runtime
Use babel-runtime instead of babel-polyfill
2 parents ffae61a + eafce33 commit bafc7bd

File tree

7 files changed

+89
-12
lines changed

7 files changed

+89
-12
lines changed

.babelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["es2015", "stage-3"]
2+
"presets": ["es2015", "stage-3"],
3+
"plugins": ["transform-runtime"]
34
}

gulpfile.babel.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
require("babel-polyfill");
2019

2120
var browserify = require('browserify');
2221
var source = require('vinyl-source-stream');
@@ -38,13 +37,16 @@ var watch = require('gulp-watch');
3837
var batch = require('gulp-batch');
3938
var replace = require('gulp-replace');
4039
var decompress = require('gulp-decompress');
41-
var fs = require("fs");
40+
var fs = require("fs-extra");
4241
var runSequence = require('run-sequence');
4342
var path = require('path');
4443
var childProcess = require("child_process");
4544
var minimist = require('minimist');
4645
var cucumber = require('gulp-cucumber');
4746
var merge = require('merge-stream');
47+
var install = require("gulp-install");
48+
var os = require('os');
49+
var file = require('gulp-file');
4850

4951
gulp.task('default', ["test"]);
5052

@@ -100,7 +102,7 @@ gulp.task('build-browser-test', function(){
100102
cache: {},
101103
debug: true
102104
}).transform(babelify.configure({
103-
presets: ['es2015', 'stage-3'], ignore: /external/
105+
presets: ['es2015', 'stage-3'], plugins: ['transform-runtime'], ignore: /external/
104106
}))
105107
.bundle(function(err, res){
106108
cb();
@@ -117,7 +119,7 @@ gulp.task('build-browser-test', function(){
117119

118120
var buildNode = function(options) {
119121
return gulp.src(options.src)
120-
.pipe(babel({presets: ['es2015', 'stage-3'], ignore: ['src/external/**/*.js']}))
122+
.pipe(babel({presets: ['es2015', 'stage-3'], plugins: ['transform-runtime'], ignore: ['src/external/**/*.js']}))
121123
.pipe(gulp.dest(options.dest))
122124
};
123125

@@ -132,6 +134,22 @@ gulp.task('all', function(cb){
132134
runSequence('nodejs', 'browser', cb);
133135
});
134136

137+
// prepares directory for package.test.js
138+
gulp.task('install-driver-into-sandbox', ['nodejs'], function(){
139+
var testDir = path.join(os.tmpdir(), 'sandbox');
140+
fs.emptyDirSync(testDir);
141+
142+
var packageJsonContent = JSON.stringify({
143+
"dependencies":{
144+
"neo4j-driver" : __dirname
145+
}
146+
});
147+
148+
return file('package.json', packageJsonContent, {src:true})
149+
.pipe(gulp.dest(testDir))
150+
.pipe(install());
151+
});
152+
135153
gulp.task('test', function(cb){
136154
runSequence('test-nodejs', 'test-browser', 'run-tck', function (err) {
137155
if (err) {
@@ -143,7 +161,7 @@ gulp.task('test', function(cb){
143161
});
144162
});
145163

146-
gulp.task('test-nodejs', ['nodejs'], function () {
164+
gulp.task('test-nodejs', ['install-driver-into-sandbox'], function () {
147165
return gulp.src('test/**/*.test.js')
148166
.pipe(jasmine({
149167
// reporter: new reporters.JUnitXmlReporter({

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
"main": "lib/index.js",
2121
"devDependencies": {
2222
"babel-core": "^6.17.0",
23-
"babel-polyfill": "^6.16.0",
23+
"babel-plugin-transform-runtime": "^6.15.0",
2424
"babel-preset-es2015": "^6.16.0",
2525
"babel-preset-stage-3": "^6.17.0",
26+
"babel-register": "^6.18.0",
2627
"babelify": "^7.3.0",
2728
"browserify": "^13.1.0",
2829
"esdoc": "^0.4.0",
2930
"esdoc-importpath-plugin": "0.0.1",
31+
"fs-extra": "^1.0.0",
3032
"glob": "^5.0.14",
3133
"gulp": "^3.9.1",
3234
"gulp-babel": "^6.1.2",
@@ -35,7 +37,9 @@
3537
"gulp-cucumber": "0.0.14",
3638
"gulp-decompress": "^1.2.0",
3739
"gulp-download": "^0.0.1",
40+
"gulp-file": "^0.3.0",
3841
"gulp-if": "^1.2.5",
42+
"gulp-install": "^0.6.0",
3943
"gulp-jasmine": "^2.1.0",
4044
"gulp-jasmine-browser": "^0.2.3",
4145
"gulp-replace": "^0.5.4",
@@ -51,5 +55,8 @@
5155
"through2": "~2.0.0",
5256
"vinyl-buffer": "^1.0.0",
5357
"vinyl-source-stream": "^1.1.0"
58+
},
59+
"dependencies": {
60+
"babel-runtime": "^6.18.0"
5461
}
5562
}

src/v1/driver.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Integer from './integer';
2323
import {connect} from "./internal/connector";
2424
import StreamObserver from './internal/stream-observer';
2525
import {newError, SERVICE_UNAVAILABLE} from "./error";
26-
import "babel-polyfill";
2726

2827
let READ = 'READ', WRITE = 'WRITE';
2928
/**

src/v1/result.js

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
import ResultSummary from './result-summary';
2121

22-
// Ensure Promise is available
23-
import "babel-polyfill";
24-
2522
/**
2623
* A stream of {@link Record} representing the result of a statement.
2724
* @access public

src/v1/routing-driver.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {newError, SERVICE_UNAVAILABLE, SESSION_EXPIRED} from "./error";
2323
import RoundRobinArray from './internal/round-robin-array';
2424
import {int} from './integer'
2525
import Integer from './integer'
26-
import "babel-polyfill";
2726

2827
/**
2928
* A driver that supports routing in a core-edge cluster.

test/v1/package.test.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright (c) 2002-2016 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
var path = require('path');
21+
var os = require('os');
22+
var NodeChannel = require('../../lib/v1/internal/ch-node').default;
23+
24+
describe('Package', function() {
25+
var driverGlobal = {close: function() {}};
26+
afterAll(function() {
27+
driverGlobal.close();
28+
});
29+
30+
it('should work', function(done){
31+
var neo4jReq;
32+
// Assuming we only run this test on NodeJS
33+
if( !NodeChannel.available ) {
34+
done();
35+
return;
36+
}
37+
38+
try {
39+
neo4jReq = require(path.join(os.tmpdir(), 'sandbox', 'node_modules', 'neo4j-driver', 'lib'));
40+
} catch(e) {
41+
done.fail('Could not load sandbox package')
42+
}
43+
44+
driverGlobal = neo4jReq.v1.driver("bolt://localhost", neo4jReq.v1.auth.basic("neo4j", "neo4j"));
45+
var session = driverGlobal.session();
46+
session.run('RETURN 1 AS answer').then(function(result) {
47+
expect(result.records.length).toBe(1);
48+
expect(result.records[0].get('answer').toNumber()).toBe(1);
49+
session.close();
50+
done();
51+
}).catch(function(e) {
52+
console.log(e);
53+
done.fail("Error in test")
54+
})
55+
})
56+
});

0 commit comments

Comments
 (0)