Skip to content

Commit

Permalink
Merge pull request #577 from ethereum/drop-require-from-string
Browse files Browse the repository at this point in the history
Drop require-from-string to restore Webpack compatibility
  • Loading branch information
chriseth authored Jan 4, 2022
2 parents d40c3f4 + 497722a commit 6f8b14c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"follow-redirects": "^1.12.1",
"js-sha3": "0.8.0",
"memorystream": "^0.3.1",
"require-from-string": "^2.0.0",
"semver": "^5.5.0",
"tmp": "0.0.33"
},
Expand Down
13 changes: 11 additions & 2 deletions wrapper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const translate = require('./translate.js');
const requireFromString = require('require-from-string');
const Module = module.constructor;
const https = require('follow-redirects').https;
const MemoryStream = require('memorystream');
const semver = require('semver');
Expand Down Expand Up @@ -335,7 +335,16 @@ function setupMethods (soljson) {
} else {
response.pipe(mem);
response.on('end', function () {
cb(null, setupMethods(requireFromString(mem.toString(), 'soljson-' + versionString + '.js')));
// Based on the require-from-string package.
const soljson = new Module();
soljson._compile(mem.toString(), 'soljson-' + versionString + '.js');
if (module.parent && module.parent.children) {
// Make sure the module is plugged into the hierarchy correctly to have parent
// properly garbage collected.
module.parent.children.splice(module.parent.children.indexOf(soljson), 1);
}

cb(null, setupMethods(soljson.exports));
});
}
}).on('error', function (error) {
Expand Down

0 comments on commit 6f8b14c

Please sign in to comment.