This will not be the full answer, but I hope it helps you in the right direction.
I have already been busy with Node's module building system in the last couple of days. Basically, I wanted to create several modules that were called in a completely new context and variable field, for which I would define a limited subset and extension of Node's capabilities.
I ended up exploring their source here and focused on the NativeModule constructor and its methods.
You will notice that the module source is read from the file, wrapped in a string representing the function, and eval'd in the actual code.
Wrapper:
NativeModule.wrapper = [ '(function (exports, require, module, __filename, __dirname, define) { ', '\n});' ];
A function is called that calls the contained module code.
A function requires half a dozen arguments, as you can see from the wrapper, the first of which is the exports object (which starts from empty). It is also passed in to the require function, so you can access require as a variable, although require not global.
The module code populates the exports object, and then exports cached, so everything that works does not need to be done in the future. Therefore, when require( 'someModule' ) , it simply scans the cached exports object and returns it.
I am sure that you could do something similar in your code while you can get the source for the required module.
Maybe for you there will be SomeModule.toString() . Not sure how compatible browser support is.
There is also a private API that is used to configure the environment for modules.
process.binding('evals').Script
I had to use createContext and runInContext to get everything working, but I think you probably won't need anything.