-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat(static-module-record): add support for import.meta #1141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s talk requirements for this feature at Endo Sync tomorrow. The Compartment abstraction will be aware of meta but not meta.url. For that, we need to give the hooks system a way to populate meta. The current notion is that the import/loadHook will be able to return an object with a meta property and the compartment will copy the properties to the meta object. Because some of those properties are expensive, we would have an importMetaHook that takes a meta object and add things like resolve but would only be called if a module utters import.meta in its source text.
See #291 |
d667716
to
63a0a28
Compare
Made some progress on the implementation. Looks like it's it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is on-track. The comments I’ve left pertain to the leading half of this feature, which needs to allow for usage like:
const c = new Compartment({}, {}, {
importHook(specifier) {
const requestUrl = locate(specifier);
const response = await fetch(requestUrl);
const responseText = await response.text();
return {
record: new StaticModuleRecord(responseText),
meta: {url: responseURL};
};
},
importMetaHook(meta) {
meta.resolve = url => importMetaResolve(url, meta.url);
},
});
d34b909
to
dfedd96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests!
8970f45
to
727c75a
Compare
packages/static-module-record/test/test-static-module-record.js
Outdated
Show resolved
Hide resolved
4da14ac
to
4f7911b
Compare
4f7911b
to
dc44516
Compare
dc44516
to
dfc4d39
Compare
@kriskowal Unless I need to put more contrnt into |
3b5d364
to
c176b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready to land, though the specification it’s based on needs a little more time to bake. Until then, I’ve left some notes for your consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…and I’m leaving a stamp so you don’t have to wait for my blessing when everything’s ready.
d61c012
to
ce2caee
Compare
…ot import.meta.something
…ns in exports + benchmark setup (#1188) * babelPlugin fix proposal and benchmarking setup * remove debris Co-authored-by: Michael FIG <mfig@agoric.com> * more cleanup
ce2caee
to
47eefca
Compare
… adhere to the compartment proposal
47eefca
to
b7cd6e7
Compare
Implemented import.meta according to #291
The actual implementation of exposing import.meta.url to modules loaded by compartment-mapper is going to be a separate PR.