16:29
<Jack Works>
In any case, I sketched this, borrowing as much as possible from the Compartments proposal https://gist.github.com/kriskowal/288d38e62e55e09685bf62c3a3c25565

The compartment will leave that promise to dangle, so an eventual rejection will necessarily go unhandled.

I don't agree with this part. If the module throws sync, it will become a sync error that can be caught, but if the promise dangles, I cannot handle it. This creates inconsistency in if module uses TLA or not

16:35
<Kris Kowal>
I also don’t like it, but couldn’t think of an alternative behavior. Answering that point consistently with the current host behavior would be ideal.
16:36
<Kris Kowal>
But also, if we reduce the scope to Module and ModuleSource constructors, I don’t believe we have to answer the question in our proposal.
16:36
<Jack Works>
Can't it spread to where the import happens?
16:36
<Kris Kowal>
Is that the behavior of dynamic import for a module and its transitive dependencies when any of them contains top-level-await?
16:37
<Kris Kowal>
Genuinely, not an expert on TLA.
16:38
<Kris Kowal>
That is, does the promise returned by dynamic import settle only when all of the transitive dependencies settle for TLA?
16:38
<Jack Works>
And I wonder how much code I need to write in the user land for the housekeeping work (e.g. module caching stuff), so I can emulate a normal ES module environment (with some built-in modules and a relative path module resolution)? I would like to see an example.
16:39
<Jack Works>
Is that the behavior of dynamic import for a module and its transitive dependencies when any of them contains top-level-await?
I believe so, otherwise what should be the result of that dynamic import?
16:40
<Kris Kowal>
The promise returned by dynamic import could settle after all first turns are completed.
16:40
<Kris Kowal>
Not that I think that’s sensible, but I don’t assume.
16:40
<Kris Kowal>
And I haven’t yet read :-)
16:41
<Kris Kowal>
In any case, I think it will be sufficient to fix that text to match whatever already exists, or delete it if we don’t have to specify the behavior in the module loader / compartments proposal.
16:42
<Kris Kowal>
As for how much needs to be done in user code, I need to write a sketch of implementing Compartment in user code, in terms of Module, ModuleSource, and ExecutionContext constructors.
16:42
<Kris Kowal>
I’m expecting to write a couple hundred lines.
16:46
<Kris Kowal>
Again, I know almost nothing about top-level-await, having not used it nor watched the proposal develop. Very much dependent on an expert to call out the right answer for sinking promises.