File tree 2 files changed +11
-3
lines changed 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 51
51
"follow-redirects" : " ^1.12.1" ,
52
52
"js-sha3" : " 0.8.0" ,
53
53
"memorystream" : " ^0.3.1" ,
54
- "require-from-string" : " ^2.0.0" ,
55
54
"semver" : " ^5.5.0" ,
56
55
"tmp" : " 0.0.33"
57
56
},
Original file line number Diff line number Diff line change 1
1
const assert = require ( 'assert' ) ;
2
2
const translate = require ( './translate.js' ) ;
3
- const requireFromString = require ( 'require-from-string' ) ;
3
+ const Module = module . constructor ;
4
4
const https = require ( 'follow-redirects' ) . https ;
5
5
const MemoryStream = require ( 'memorystream' ) ;
6
6
const semver = require ( 'semver' ) ;
@@ -335,7 +335,16 @@ function setupMethods (soljson) {
335
335
} else {
336
336
response . pipe ( mem ) ;
337
337
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 ) ) ;
339
348
} ) ;
340
349
}
341
350
} ) . on ( 'error' , function ( error ) {
You can’t perform that action at this time.
0 commit comments