diff --git a/README.md b/README.md index e48ae8e..4f2f8ea 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,27 @@ Since `d` uses top-level await, `d` and its dependencies cannot be deferred: - The initial evaluation will execute `b`, `e`, `d` and `a`. - Later, the `c.value` access will trigger the execution of `f` and `c`. +This is equivalent to "transpiling" the `import defer * as c from "c"` declaration to: +- direct eager import declarations to its async transitive dependencies +- eager loading/linking of `c` +- lazy evaluation of `c` + +```js +// import c's async transitive dependencies +import "d"; +// load c without evaluating it. +loadAndLinkSync("c"); +// evaluate on property access +const c = new Proxy({}, { + get(namespace, prop) { + const promise = evaluate("c"); + assert(promise.[[Status]] === "fulfilled"); + const namespace = promise.[[Value]]; + return namespace[prop]; + } +}); +``` + ### Rough sketch If we split out the components of Module loading and initialization, we could roughly sketch out the