Removing a module from the cache

Isiah Meadows isiahmeadows at gmail.com
Thu Sep 20 18:33:38 UTC 2018


I could seriously use the ability to remove, relative to a module, a
loaded module from the cache.

- In my test runner, I don't want to have to append a random query
just to reload all the test files in watch mode.
- I was at one point running an experiment to try to use JS tagged
templates as a template engine of sorts, but I can't really use ES
modules because I need the ability to drop them from cache and
re-import them manually.

I do not require any new syntax (it can just be a built-in exposed to
hosts and maybe by hosts like Node), but I would like such a hook
exposed.

This won't require much in the spec, but it will require three main
spec changes:

- A new per-realm specifier blacklist (like maybe realm.[[Reload]]) added.
- The third requirement in `HostResolveImportedModule` [1] altered to not
require idempotence when the specifier is in the current realm's
[[Reload]] list.
- All callees to `HostResolveImportedModule` changed to also remove
the specifier from the current realm's [[Reload]] list if the
operation completed normally.

[1]: https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule

-----

Isiah Meadows
contact at isiahmeadows.com
www.isiahmeadows.com


More information about the es-discuss mailing list