mirror of https://github.com/embarklabs/embark.git
Extract global and web3js
This commit is contained in:
parent
83c01cffdc
commit
a8c5205b67
|
@ -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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue