In the node js module system, to use require(), one must have the file path of the module as such —
const foo = require('/path/to/bar');
foo();
However, say I have a javascript file in memory, whose contents I know, but not the path. How can i simulate —
const foo = customRequire(/* contents of the file as string */)
foo();
Is there a better way than to just eval() the string ?