Skip to content

Commit 6f8b14c

Browse files
authored
Merge pull request #577 from ethereum/drop-require-from-string
Drop require-from-string to restore Webpack compatibility
2 parents d40c3f4 + 497722a commit 6f8b14c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"follow-redirects": "^1.12.1",
5252
"js-sha3": "0.8.0",
5353
"memorystream": "^0.3.1",
54-
"require-from-string": "^2.0.0",
5554
"semver": "^5.5.0",
5655
"tmp": "0.0.33"
5756
},

wrapper.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const assert = require('assert');
22
const translate = require('./translate.js');
3-
const requireFromString = require('require-from-string');
3+
const Module = module.constructor;
44
const https = require('follow-redirects').https;
55
const MemoryStream = require('memorystream');
66
const semver = require('semver');
@@ -335,7 +335,16 @@ function setupMethods (soljson) {
335335
} else {
336336
response.pipe(mem);
337337
response.on('end', function () {
338-
cb(null, setupMethods(requireFromString(mem.toString(), 'soljson-' + versionString + '.js')));
338+
// Based on the require-from-string package.
339+
const soljson = new Module();
340+
soljson._compile(mem.toString(), 'soljson-' + versionString + '.js');
341+
if (module.parent && module.parent.children) {
342+
// Make sure the module is plugged into the hierarchy correctly to have parent
343+
// properly garbage collected.
344+
module.parent.children.splice(module.parent.children.indexOf(soljson), 1);
345+
}
346+
347+
cb(null, setupMethods(soljson.exports));
339348
});
340349
}
341350
}).on('error', function (error) {

0 commit comments

Comments
 (0)