Clarification on exposing host modules to a mod running in a Container #1273
Replies: 1 comment
-
Compartments is definitely an advanced topic. They work well, but since the proposal is still evolving documentation is limited. To provide access to modules, you can either use the module map ( new Compartment({
resolveHook(importSpecifier, referrerSpecifier) {
return importSpecifier;
},
loadNowHook(specifier) {
return {namespace: specifier};
}
}); N.B. This isn't a complete example -- you still need to set-up any other Compartment options. Also, it doesn't support relative module imports (ignores referrerSpecifier argument). But, it should help you move forward. |
Beta Was this translation helpful? Give feedback.
-
I'm seeking clarification on the proper way to grant access for included host modules to a mod running inside a Container...
I've read the online documentation on the website for the Component API, gone over the code examples in the repository, read though the draft TC39/SES draft specs, and spent time grokking the relevant code in xsModules.c and I'm still a little fuzzy on the actual Component API implementation used by the XS engine...
As an example; how would I create a Compartment that allowed the loaded mod to use the following statement?
import {} from "piu/MC"
Currently I'm using the globals property to inject imported modules from the host, but I'm assuming there's a less ham-fisted way of doing this?
Corollary question; is there a way to create a Compartment with 'no security' - ie: expose all of the host to the module inside the Comparment?
Beta Was this translation helpful? Give feedback.
All reactions