diff --git a/gulpfile.js b/gulpfile.js index 29130d42b..3a62601f8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -69,7 +69,11 @@ gulp.task('build:browser', ['lint:src'], function() { .pipe(plugins.insert.prepend(fs.readFileSync('./node_modules/event-source-polyfill/eventsource.js'))) .pipe(plugins.rename('stellar-sdk.js')) .pipe(gulp.dest('dist')) - .pipe(plugins.uglify()) + .pipe(plugins.uglify({ + output: { + ascii_only: true + } + })) .pipe(plugins.rename('stellar-sdk.min.js')) .pipe(gulp.dest('dist')); }); diff --git a/package.json b/package.json index 726e876a8..34a63d21a 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "eventsource": "^0.1.6", "jsdoc": "jsdoc3/jsdoc#master", "lodash": "^4.0.1", - "stellar-base": "^0.5.3", + "stellar-base": "^0.5.4", "superagent": "^1.1.0", "toml": "^2.3.0" } diff --git a/src/browser.js b/src/browser.js index 4df7703dc..129552e96 100644 --- a/src/browser.js +++ b/src/browser.js @@ -4,3 +4,6 @@ module.exports = require("./index"); module.exports.axios = require("axios"); module.exports.bluebird = require("bluebird"); module.exports.StellarBase = require("stellar-base"); + +/*globals _*/ +_.noConflict(); diff --git a/src/call_builder.js b/src/call_builder.js index 00b9ad621..7dd214877 100644 --- a/src/call_builder.js +++ b/src/call_builder.js @@ -1,4 +1,5 @@ import {NotFoundError, NetworkError, BadRequestError} from "./errors"; +import forEach from 'lodash/forEach'; let URI = require("urijs"); let URITemplate = require("urijs").URITemplate; @@ -6,7 +7,6 @@ let URITemplate = require("urijs").URITemplate; let axios = require("axios"); var EventSource = (typeof window === 'undefined') ? require('eventsource') : window.EventSource; let toBluebird = require("bluebird").resolve; -let _ = require('lodash'); /** * Creates a new {@link CallBuilder} pointed to server defined by serverUrl. @@ -97,7 +97,7 @@ export class CallBuilder { if (!json._links) { return json; } - _.forEach(json._links, (n, key) => {json[key] = this._requestFnForLink(n);}); + forEach(json._links, (n, key) => {json[key] = this._requestFnForLink(n);}); return json; } diff --git a/src/federation_server.js b/src/federation_server.js index 4dd16e929..c46eafeb3 100644 --- a/src/federation_server.js +++ b/src/federation_server.js @@ -2,7 +2,8 @@ import axios from 'axios'; import URI from 'urijs'; import Promise from 'bluebird'; import toml from 'toml'; -import {isString, pick} from "lodash"; +import isString from "lodash/isString"; +import pick from "lodash/pick"; import {Account} from 'stellar-base'; export class FederationServer { diff --git a/src/server.js b/src/server.js index f95e980f6..6d2fc80c9 100644 --- a/src/server.js +++ b/src/server.js @@ -11,8 +11,7 @@ import {PaymentCallBuilder} from "./payment_call_builder"; import {EffectCallBuilder} from "./effect_call_builder"; import {FriendbotBuilder} from "./friendbot_builder"; import {xdr, Account} from "stellar-base"; - -import {isString} from "lodash"; +import isString from "lodash/isString"; let axios = require("axios"); let toBluebird = require("bluebird").resolve; diff --git a/test/unit/browser_test.js b/test/unit/browser_test.js new file mode 100644 index 000000000..05c7bffd4 --- /dev/null +++ b/test/unit/browser_test.js @@ -0,0 +1,7 @@ +describe('Browser version tests', function() { + it("lodash is not exported globally", function () { + if (typeof window !== "undefined") { + expect(_).to.be.undefined; + } + }); +});