| 00:49 | <nicolo-ribaudo> | nicolo-ribaudo: Caridy is working on First-class Modules spec text. It might be good for you to connect. Awesome! This week I started refactoring the I now have a single This is my proposed refactor: https://nicolo-ribaudo.github.io/modules-import-hooks-refactor/ I believe that the new logic closely resembles the loading logic introduced by "layer 0": we could probably just add a step tocheck to 2.d.ii of InnerModuleLoading that calls a It would probably also help with module reflection: assuming that I would love to hear your thoughts on this 🙂 |
| 00:53 | <Kris Kowal> | Your description matches my intuition. |
| 00:54 | <Kris Kowal> | Though, it would be nice if we could always route through module.[[ImportHook]], even when that is just a thunk for HostLoadImportedModule. |
| 00:55 | <littledan> | I reviewed this refactor earlier today and it looks great to me. |
| 00:55 | <Kris Kowal> | And I think this generally closes the gap with Caridy’s upcoming changes, which had no reasonable default importHook. |
| 00:58 | <littledan> | This refactor is great because it makes it clear exactly where importHook is called; it is not too often as currently |
| 01:00 | <littledan> | IMO it would make sense to land separately in HTML and JS already, since it is a significant cleanup, or at least put out for review as a separated item |
| 01:05 | <Kris Kowal> | Would it be reasonable for HostLoadImportedModule to be the default [[ImportHook]] of a Realm, such that Module instances and module blocks can pick it up from their execution context? |
| 01:05 | <Kris Kowal> | That should be behaviorally equivalent, I think. |
| 01:06 | <Kris Kowal> | Or rather, in the case of the Module constructor, picked up from the ModuleConstructor.[[Context]].[[Realm]].[[ImportHook]] |
| 01:07 | <nicolo-ribaudo> | Though, it would be nice if we could always route through module.[[ImportHook]], even when that is just a thunk for HostLoadImportedModule. Promise.resolve on [[ImportHook]]()'s result, because its an user-exposed API. This forces a microtask for every imported module, while the old HostResolveImportedModule allowed everything to be synchronous (the new .LoadRequiredModule always returns a promise, but hosts can implement a sync HostLoadImportedModule and then .LoadRequiredModule always returns an already resolved promise) |
| 01:08 | <Kris Kowal> | I see. |
| 01:09 | <Kris Kowal> | I think the ends I’m looking for could be accomplished another way, then… |
| 01:09 | <nicolo-ribaudo> | I know that Bun (a new experimental JS runtime) allows require() of ESM, and throws if it uses TLA. So there is at least one project that depends on modules loadnig being mostly synchroous (without TLA, .Evaluate() returns an already resolved promise) |
| 01:09 | <Kris Kowal> | That is, for there to be a slot that the HostLoadImportedModule fits into, which a VirtualHostLoadImportedModule would fit in. |
| 01:10 | <nicolo-ribaudo> | That is, for there to be a slot that the HostLoadImportedModule fits into, which a VirtualHostLoadImportedModule would fit in. |
| 01:10 | <Kris Kowal> | Yeah, I’m familiar with Bun. It makes some similar architectural choices to Endo. |
| 01:11 | <Kris Kowal> | Or rather is born from similar requirements: All things must bundle. |
| 01:15 | <nicolo-ribaudo> | Kris Kowal Do you know what's the best way to share my refactor with Caridy? I see that he's not in this room. |
| 03:36 | <Jack Works> | Did a quick scan over the refactor spec:
Module block spec:
|
| 05:02 | <littledan> | To review these PRs, understand the ModuleBlock class to stand for Module/ModuleInstance |
| 05:03 | <littledan> | Since we are talking about instances, they exist just within one module graph and therefore one realm. You can make a different module instance (eg with structured clone) to get something similar but within another module graph |
| 05:06 | <littledan> | Yes, this change is normative, since it makes all environments follow some of the logic that is currently in HTML. I think this logic is pretty reasonable and makes sense to apply universally but we should be careful to examine the various environments that we have to make sure that is appropriate. |
| 05:07 | <littledan> | How does ContinueDynamicImport Link/Evaluate the same thing multiple times? I agree that it shouldn’t do that |
| 05:08 | <littledan> | I agree that the source might not always be visible to JS code. How does that relate to these patches? |
| 05:10 | <littledan> | About AbstractModuleRecord vs CyclicModuleRecord: currently, the notion of an import/dependency is all in CyclicModuleRecord. We could generalize this but I think it would help to have a driving use case where we don’t want to use CyclicModuleRecord, which I can’t think of. This refactoring seems orthogonal to the current PR. |
| 07:15 | <guybedford> | nicolo-ribaudo: great to see! Will review further over the weekend. Did you mean to also include the updates to HostResolveImportedModule calls in InnerModuleLinking and InnerModuleEvaluation? I didn't see those included. |
| 10:45 | <nicolo-ribaudo> | Thanks or the review!
Regarding module blocks: yes, the spec still needs to be updated after the harmony discussions in the last week, I only rewrote the current state of the proposal. |
| 10:45 | <nicolo-ribaudo> | nicolo-ribaudo: great to see! Will review further over the weekend. Did you mean to also include the updates to HostResolveImportedModule calls in InnerModuleLinking and InnerModuleEvaluation? I didn't see those included. |
| 23:36 | <guybedford> | Okay, I just would have thought that the InnerModuleLinking logic repeats a lot of the payload logic you have. |