Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Worker's initially loaded module should have module.id == require.main #74

Open
kriszyp opened this issue Nov 19, 2009 · 1 comment
Open

Comments

@kriszyp
Copy link

kriszyp commented Nov 19, 2009

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.

@kriskowal
Copy link
Collaborator

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants