File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 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 },
Original file line number Diff line number Diff line change 11const assert = require ( 'assert' ) ;
22const translate = require ( './translate.js' ) ;
3- const requireFromString = require ( 'require-from-string' ) ;
3+ const Module = module . constructor ;
44const https = require ( 'follow-redirects' ) . https ;
55const MemoryStream = require ( 'memorystream' ) ;
66const 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 ) {
You can’t perform that action at this time.
0 commit comments