I'd like to have the ability to define a module that is cached
per-module rather than globally on import. Maybe something like this,
defined only for modules:
// Creates a new constant read-only proxy to parent `import.meta`,
// limits caching to just this one parent module.
import from parent;
As for use cases, here's a few:
- proxyquire, which currently does an uncached `require` in CommonJS
to gain reliable access to the parent module. If top-level await is
added, they could instead do a single default export returning the
namespace for the method.
- My invoke-parallel does similar, to allow for implicit parallelism
of exported methods, and I currently can't support ESM without a
This proposal is about as simple as I can think of while still
providing the minimum required functionality.