runInNewContext not intended to replace require or eval , but instead as a way to create a sandbox environment where you can safely run other scripts.
The disadvantages are that it is slow (creation takes ~ 10 ms) and takes a couple of megabytes. Therefore, no, do not use it as a replacement for require .
source share