Commit 748aef29 authored by Iuri Matias's avatar Iuri Matias

make compiler more node friendly

parent 2e2d9df3
...@@ -24,13 +24,15 @@ ...@@ -24,13 +24,15 @@
"remix-core": "latest", "remix-core": "latest",
"remix-lib": "latest", "remix-lib": "latest",
"webworkify": "^1.2.1", "webworkify": "^1.2.1",
"solc": "^0.4.13", "solc": "https://github.com/ethereum/solc-js",
"npm-run-all": "^4.0.2",
"standard": "^7.0.1", "standard": "^7.0.1",
"tape": "^4.6.0" "tape": "^4.6.0"
}, },
"scripts": { "scripts": {
"test": "standard && npm run downloadsolc && tape ./test/tests.js", "test": "standard && npm run downloadsolc && tape ./test/tests.js",
"downloadsolc": "test -e soljson.js || wget https://ethereum.github.io/solc-bin/soljson.js" "downloadsolc": "cd node_modules/solc && (test -e soljson.js || wget https://ethereum.github.io/solc-bin/soljson.js) && cd ..",
"prepublish": "mkdirp build; npm-run-all -ls downloadsolc"
}, },
"standard": { "standard": {
"ignore": [ "ignore": [
......
...@@ -72,7 +72,12 @@ function Compiler (handleImportCall) { ...@@ -72,7 +72,12 @@ function Compiler (handleImportCall) {
function onInternalCompilerLoaded () { function onInternalCompilerLoaded () {
if (worker === null) { if (worker === null) {
var compiler = solc(window.Module) var compiler;
if (typeof(window) == 'undefined') {
compiler = require('solc');
} else {
compiler = solc(window.Module)
}
compileJSON = function (source, optimize, cb) { compileJSON = function (source, optimize, cb) {
var missingInputs = [] var missingInputs = []
...@@ -95,6 +100,7 @@ function Compiler (handleImportCall) { ...@@ -95,6 +100,7 @@ function Compiler (handleImportCall) {
onCompilerLoaded(compiler.version()) onCompilerLoaded(compiler.version())
} }
} }
this.onInternalCompilerLoaded = onInternalCompilerLoaded; // exposed for use in node
this.lastCompilationResult = { this.lastCompilationResult = {
data: null, data: null,
...@@ -215,6 +221,7 @@ function Compiler (handleImportCall) { ...@@ -215,6 +221,7 @@ function Compiler (handleImportCall) {
} }
} }
// TODO: needs to be changed to be more node friendly
this.loadVersion = function (usingWorker, url) { this.loadVersion = function (usingWorker, url) {
console.log('Loading ' + url + ' ' + (usingWorker ? 'with worker' : 'without worker')) console.log('Loading ' + url + ' ' + (usingWorker ? 'with worker' : 'without worker'))
self.event.trigger('loadingCompiler', [url, usingWorker]) self.event.trigger('loadingCompiler', [url, usingWorker])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment