A Compartment object abstracts the notion of a distinct global environment, with its own global object, copy of the standard library, but shares the "intrinsics" (standard objects that are not bound to global variables, like the initial value of Object.prototype) with the current execution environment.
class Compartment {
constructor: (
globals : object?, // extra globals added to the global object
modules: object?, // module map, specifier to specifier
) -> object,
// public methods
import(specifier: string) -> promise, // same argument/return value as dynamic import
// inherited accessor properties
get global() -> object, // access this compartment global object
}
Place all files in a moddable examples/js/compartments/SESCompartment
folder then open XSBug, cd into the directory from termial, and run mcconfig -m -d
at the command-line.
[object Object]mod1
g1 original value
mod1 done.