electron-sandbox-boilerplate icon indicating copy to clipboard operation
electron-sandbox-boilerplate copied to clipboard

Experimental feature: require = null in preload

Open kewde opened this issue 7 years ago • 1 comments

I've added an experimental feature to the preload script that will set require() = null after it's done importing. Feedback? https://github.com/kewde/electron-sandbox-boilerplate/blob/401b293066aeb185741852f059cdf0a46e70f1bf/sandbox-preload-extended/electron/renderer/preload-extended.js#L13-L23

What I hope it will achieve: disallow the loading of other modules after this line..

kewde avatar Jan 13 '18 18:01 kewde

This dereferences the code behind the require function, making it potentially eligible for garbage collection? The gc isn't automatically triggered tho, so something like this would be required. https://simonmcmanus.wordpress.com/2013/01/03/forcing-garbage-collection-with-node-js-and-v8/

kewde avatar Jan 13 '18 21:01 kewde