diff --git a/lib/core/modules/coderunner/codeRunner.js b/lib/core/modules/coderunner/codeRunner.js index 1e98850b1..c4b471de1 100644 --- a/lib/core/modules/coderunner/codeRunner.js +++ b/lib/core/modules/coderunner/codeRunner.js @@ -36,6 +36,9 @@ class CodeRunner { this.runCode.registerVar('Web3', Web3); this.runCode.registerVar('EmbarkJS', EmbarkJS); this.events.on('code-generator-ready', () => { + this.events.request('code-generator:web3js', ((_err, code) => { + this.runCode.doEval(code); + })); this.events.request('code-generator:embarkjs:provider-code', (code) => { this.runCode.doEval(code); const codeTypes = { diff --git a/lib/core/modules/coderunner/runCode.js b/lib/core/modules/coderunner/runCode.js index cdf3b5ae5..4dcac3a69 100644 --- a/lib/core/modules/coderunner/runCode.js +++ b/lib/core/modules/coderunner/runCode.js @@ -2,7 +2,7 @@ const vm = require('vm'); class RunCode { constructor() { - this.context = Object.assign({}, {console, exports, require, module, __filename, __dirname}, global.this); + this.context = Object.assign({}, {global, console, exports, require, module, __filename, __dirname}); } doEval(code) { diff --git a/lib/modules/code_generator/index.js b/lib/modules/code_generator/index.js index cd5dfdf81..966fc51cb 100644 --- a/lib/modules/code_generator/index.js +++ b/lib/modules/code_generator/index.js @@ -379,7 +379,6 @@ 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') {"; @@ -390,7 +389,6 @@ class CodeGenerator { let providerCode = self.generateProvider(false); code += providerCode; code += "\nglobal.__embarkContext = __mainContext.__loadManagerInstance;\n"; - code += "\nexport default web3;\n"; next(null, code); } ], cb);