-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receive the module instance in importMetaHook? #13
Comments
See https://github.com/tc39/proposal-realms/issues/244#issuecomment-633180485 The Compartment proposal has an importMetaHook. This hook is expected to stay in the Compartment proposal, as it relates (loosely) to importing. |
I have updated the issue to reflect the latest compartment API. |
Do you mean ModuleExportsNamespace? What’s a motivating use-case? That is, how would this feature be used? |
This is my motivating use case although it is not common. |
Do you mean to build a Map of all the compartment’s instances by their full specifier? Do you need a reified instance or do you need the module exports namespace? |
The case seems incomplete, since the object resolved by import is the module exports namespace (so presumably the module in question exports What would you go on to do with these objects? |
const x = new Compartment({
// ...
importMetaHook(fullSpec, meta, moduleInsance) {
meta.url = fullSpec
meta.self = moduleInstance
}
})
await x.import("/index")
export const x = 1
import.meta.self.x = 1;
(await import('/index')) === import.meta.self Yes, I agree this use case does not look so compelling so maybe we can ignore it. |
Example:
The text was updated successfully, but these errors were encountered: