diff --git a/lib/core/modules/coderunner/runCode.js b/lib/core/modules/coderunner/runCode.js index 4dcac3a69..ce269d8b9 100644 --- a/lib/core/modules/coderunner/runCode.js +++ b/lib/core/modules/coderunner/runCode.js @@ -20,6 +20,7 @@ class RunCode { if (varName === 'web3') { global.web3 = code; } + this.context["global"][varName] = code; this.context[varName] = code; } diff --git a/lib/modules/code_generator/index.js b/lib/modules/code_generator/index.js index 966fc51cb..cd5dfdf81 100644 --- a/lib/modules/code_generator/index.js +++ b/lib/modules/code_generator/index.js @@ -379,6 +379,7 @@ 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') {"; @@ -389,6 +390,7 @@ class CodeGenerator { let providerCode = self.generateProvider(false); code += providerCode; code += "\nglobal.__embarkContext = __mainContext.__loadManagerInstance;\n"; + code += "\nexport default web3;\n"; next(null, code); } ], cb); diff --git a/templates/demo/app/components/ens.js b/templates/demo/app/components/ens.js index 64e5a4e2a..b5dd7c223 100644 --- a/templates/demo/app/components/ens.js +++ b/templates/demo/app/components/ens.js @@ -146,7 +146,7 @@ class ENS extends React.Component { -