Uncached modules

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Uncached modules

Isiah Meadows-2
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
similar facility.

This proposal is about as simple as I can think of while still
providing the minimum required functionality.


Isiah Meadows
[hidden email]
es-discuss mailing list
[hidden email]