Module sandbox

azproduction edited this page Jan 31, 2013 · 2 revisions
  • Module parameters: sandbox

If you are using some untrusted 3-party modules or your modules cant require() by design. You can apply sandbox on that module by adding "sandbox": true to your module declaration. Now this module can't require and use require sub-functions. undefined or Object (if module under Code Coverage) will passed as require. Sandboxed module can export all module stuff.

"third_party_module_b": {
    "path": "vendors/other_module.js",
    "sandbox": true,
    "exports": {
        "pewpew": "pewpew",
        "ololo": "ololo",
        "someVariable": "someVariable"
    }
}

See demo, code