diff --git a/index.js b/index.js index 6e5bad6..3925e5f 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,5 @@ var Profiler = require("./profiler"); var OS = require("os"); -var solc = require("solc"); - -// Clean up after solc. -var listeners = process.listeners("uncaughtException"); -var solc_listener = listeners[listeners.length - 1]; - -if (solc_listener) { - process.removeListener("uncaughtException", solc_listener); -} var path = require("path"); var fs = require("fs"); @@ -45,6 +36,17 @@ var compile = function(sources, options, callback) { "solc" ]); + // Load solc module only when compilation is actually required. + var solc = require("solc"); + // Clean up after solc. + var listeners = process.listeners("uncaughtException"); + var solc_listener = listeners[listeners.length - 1]; + + if (solc_listener) { + process.removeListener("uncaughtException", solc_listener); + } + + // Ensure sources have operating system independent paths // i.e., convert backslashes to forward slashes; things like C: are left intact. var operatingSystemIndependentSources = {};