diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index af91b6dda..9cae038c4 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -287,7 +287,7 @@ class CodeGenerator { const self = this; let embarkjsCode = "import EmbarkJS from 'embarkjs';"; embarkjsCode += "\nexport default EmbarkJS;"; - embarkjsCode += "\nwindow.EmbarkJS = EmbarkJS"; + embarkjsCode += "\nglobal.EmbarkJS = EmbarkJS"; let code = ""; async.waterfall([ @@ -365,17 +365,16 @@ class CodeGenerator { function getImports(web3Location, next) { web3Location = web3Location.replace(/\\/g, '/'); // Import paths must always have forward slashes code += "\nimport Web3 from '" + web3Location + "';\n"; + code += "\nglobal.Web3 = Web3;\n"; - code += "\n if (typeof web3 !== 'undefined') {"; - code += "\n } else {"; + code += "\n if (typeof web3 === 'undefined') {"; code += "\n var web3 = new Web3();\n"; code += "\n }"; + code += "\nglobal.web3 = web3;\n"; let providerCode = self.generateProvider(false); code += providerCode; code += "\nglobal.__embarkContext = __mainContext.__loadManagerInstance;\n"; - code += "\nwindow.Web3 = Web3;\n"; - code += "\nwindow.web3 = web3;\n"; code += "\nexport default web3;\n"; next(null, code); }