Skip to content
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

Question for vendors: Can we reveal host-defined loadHook and resolveHook? #63

Open
kriskowal opened this issue Jun 14, 2022 · 2 comments

Comments

@kriskowal
Copy link
Member

Realms and Compartments (as module-loaders) have a host-defined load hook and a resolve hook. In #50, we are considering ways that the host-defined hooks could be passed from host to guest. There is a way to make this work without ever revealing the loadHook or resolveHook to user code, only revealing their behavior as a side-effect of using a compartment. However, the design may be simpler if we simply revealed the host compartment’s hooks, for example as Compartment.loadHook and Compartment.resolveHook static methods, or like a parentLoadHook argument to loadHook.

Would it be possible to expose these functions such that user code could call it directly, or pass it to a new compartment?

Summary of the proposed hooks: loadHook(specifier: string) returns a promise for a “module descriptor”, which in turn may contain a StaticModuleRecord or a synthetic static module record. The descriptor may also provide a bag of importMeta properties, and other module descriptors indicate aliases from one specifier to another. The resolveHook is synchronous and produces memoization table keys from import specifiers and the referrer specifier.

@kriskowal
Copy link
Member Author

kriskowal commented Jun 14, 2022

@Jamesernator and @naugtur point us at Node.js experimental loader documentation https://nodejs.org/api/esm.html#hooks (via #50 (comment))

Which suggests, categorically, Node.js would be fine revealing its host hooks to guest code. So, we can narrow the question to whether browser vendors could do the same.

@kriskowal
Copy link
Member Author

kriskowal commented Jun 14, 2022

Capturing for the record, @syg’s feedback:

my intuition is a strong "preferably not" [expose the host hooks]

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

No branches or pull requests

1 participant