Open kriszyp opened 14 years ago
If you instantiate a Sandbox by calling SANDBOX.sandbox(id, system, options), the id module will be the main. If you instantiate a sandbox with the Sandbox constructor, you can call Sandbox(options).main(id) to start it with that module as the main.
I think that the target module of a worker (the one indicated in the Worker constructor) should be able to detect that it is the initial module, presumably with (module.id == require.main). In worker.js I have tried setting workerGlobal.require.main = scriptName, but that does not seem to affect the require.main that is provided to the modules in the worker environment. I am not sure how one is supposed to set require.main.