From 3ecb195b388f4e480f774a036bdf592709b95949 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 9 Apr 2018 16:29:49 -0400 Subject: [PATCH] move import list out of loop to accelerate build process --- lib/pipeline/pipeline.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index 72616c3be..dfd49d01b 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -26,6 +26,23 @@ class Pipeline { self.buildWeb3JS(function() { + let importsList = {}; + + importsList["Embark/EmbarkJS"] = fs.dappPath(".embark", 'embark.js'); + importsList["Embark/web3"] = fs.dappPath(".embark", 'web3_instance.js'); + + self.plugins.getPluginsProperty('imports', 'imports').forEach(function (importObject) { + let [importName, importLocation] = importObject; + importsList[importName] = importLocation; + }); + + for (let contractName in contractsJSON) { + let contractCode = self.buildContractJS(contractName); + let filePath = fs.dappPath(".embark", contractName + '.js'); + fs.writeFileSync(filePath, contractCode); + importsList["Embark/contracts/" + contractName] = filePath; + } + // limit:1 due to issues when downloading required files such as web3.js async.eachOfLimit(self.assetFiles, 1, function (files, targetFile, cb) { // limit:1 due to issues when downloading required files such as web3.js @@ -34,22 +51,6 @@ class Pipeline { self.logger.trace("reading " + file.filename); if (file.filename.indexOf('.js') >= 0) { - let importsList = {}; - - importsList["Embark/EmbarkJS"] = fs.dappPath(".embark", 'embark.js'); - importsList["Embark/web3"] = fs.dappPath(".embark", 'web3_instance.js'); - - self.plugins.getPluginsProperty('imports', 'imports').forEach(function (importObject) { - let [importName, importLocation] = importObject; - importsList[importName] = importLocation; - }); - - for (let contractName in contractsJSON) { - let contractCode = self.buildContractJS(contractName); - let filePath = fs.dappPath(".embark", contractName + '.js'); - fs.writeFileSync(filePath, contractCode); - importsList["Embark/contracts/" + contractName] = filePath; - } let realCwd;