Skip to content

Use babel-runtime instead of babel-polyfill #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["es2015", "stage-3"]
"presets": ["es2015", "stage-3"],
"plugins": ["transform-runtime"]
}
28 changes: 23 additions & 5 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require("babel-polyfill");

var browserify = require('browserify');
var source = require('vinyl-source-stream');
Expand All @@ -38,13 +37,16 @@ var watch = require('gulp-watch');
var batch = require('gulp-batch');
var replace = require('gulp-replace');
var decompress = require('gulp-decompress');
var fs = require("fs");
var fs = require("fs-extra");
var runSequence = require('run-sequence');
var path = require('path');
var childProcess = require("child_process");
var minimist = require('minimist');
var cucumber = require('gulp-cucumber');
var merge = require('merge-stream');
var install = require("gulp-install");
var os = require('os');
var file = require('gulp-file');

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

Expand Down Expand Up @@ -100,7 +102,7 @@ gulp.task('build-browser-test', function(){
cache: {},
debug: true
}).transform(babelify.configure({
presets: ['es2015', 'stage-3'], ignore: /external/
presets: ['es2015', 'stage-3'], plugins: ['transform-runtime'], ignore: /external/
}))
.bundle(function(err, res){
cb();
Expand All @@ -117,7 +119,7 @@ gulp.task('build-browser-test', function(){

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

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

// prepares directory for package.test.js
gulp.task('install-driver-into-sandbox', ['nodejs'], function(){
var testDir = path.join(os.tmpdir(), 'sandbox');
fs.emptyDirSync(testDir);

var packageJsonContent = JSON.stringify({
"dependencies":{
"neo4j-driver" : __dirname
}
});

return file('package.json', packageJsonContent, {src:true})
.pipe(gulp.dest(testDir))
.pipe(install());
});

gulp.task('test', function(cb){
runSequence('test-nodejs', 'test-browser', 'run-tck', function (err) {
if (err) {
Expand All @@ -143,7 +161,7 @@ gulp.task('test', function(cb){
});
});

gulp.task('test-nodejs', ['nodejs'], function () {
gulp.task('test-nodejs', ['install-driver-into-sandbox'], function () {
return gulp.src('test/**/*.test.js')
.pipe(jasmine({
// reporter: new reporters.JUnitXmlReporter({
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
"main": "lib/index.js",
"devDependencies": {
"babel-core": "^6.17.0",
"babel-polyfill": "^6.16.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-3": "^6.17.0",
"babel-register": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"esdoc": "^0.4.0",
"esdoc-importpath-plugin": "0.0.1",
"fs-extra": "^1.0.0",
"glob": "^5.0.14",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
Expand All @@ -35,7 +37,9 @@
"gulp-cucumber": "0.0.14",
"gulp-decompress": "^1.2.0",
"gulp-download": "^0.0.1",
"gulp-file": "^0.3.0",
"gulp-if": "^1.2.5",
"gulp-install": "^0.6.0",
"gulp-jasmine": "^2.1.0",
"gulp-jasmine-browser": "^0.2.3",
"gulp-replace": "^0.5.4",
Expand All @@ -51,5 +55,8 @@
"through2": "~2.0.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"dependencies": {
"babel-runtime": "^6.18.0"
}
}
1 change: 0 additions & 1 deletion src/v1/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Integer from './integer';
import {connect} from "./internal/connector";
import StreamObserver from './internal/stream-observer';
import {newError, SERVICE_UNAVAILABLE} from "./error";
import "babel-polyfill";

let READ = 'READ', WRITE = 'WRITE';
/**
Expand Down
3 changes: 0 additions & 3 deletions src/v1/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

import ResultSummary from './result-summary';

// Ensure Promise is available
import "babel-polyfill";

/**
* A stream of {@link Record} representing the result of a statement.
* @access public
Expand Down
1 change: 0 additions & 1 deletion src/v1/routing-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {newError, SERVICE_UNAVAILABLE, SESSION_EXPIRED} from "./error";
import RoundRobinArray from './internal/round-robin-array';
import {int} from './integer'
import Integer from './integer'
import "babel-polyfill";

/**
* A driver that supports routing in a core-edge cluster.
Expand Down
56 changes: 56 additions & 0 deletions test/v1/package.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var path = require('path');
var os = require('os');
var NodeChannel = require('../../lib/v1/internal/ch-node').default;

describe('Package', function() {
var driverGlobal = {close: function() {}};
afterAll(function() {
driverGlobal.close();
});

it('should work', function(done){
var neo4jReq;
// Assuming we only run this test on NodeJS
if( !NodeChannel.available ) {
done();
return;
}

try {
neo4jReq = require(path.join(os.tmpdir(), 'sandbox', 'node_modules', 'neo4j-driver', 'lib'));
} catch(e) {
done.fail('Could not load sandbox package')
}

driverGlobal = neo4jReq.v1.driver("bolt://localhost", neo4jReq.v1.auth.basic("neo4j", "neo4j"));
var session = driverGlobal.session();
session.run('RETURN 1 AS answer').then(function(result) {
expect(result.records.length).toBe(1);
expect(result.records[0].get('answer').toNumber()).toBe(1);
session.close();
done();
}).catch(function(e) {
console.log(e);
done.fail("Error in test")
})
})
});