Removing a module from the cache

kai zhu kaizhu256 at gmail.com
Mon Sep 24 08:46:46 UTC 2018


hi Isiah, i don’t feel your use-case is a valid one.  i've played with many crazy hot-module loading-techniques in my 7 years as a python-dev, and afterwards, first year as js-dev.  reflecting on all that time spent, what have i learned?  that for anything besides contrived toy-cases, i *never* trusted the modules would hot-load correctly, with properly resolved dependencies (especially inter-module class-inheritances, which was a factor why i'm hostile to inheritance-based design-patterns in dynamics-languages).  in practice i always ended up restarting the entire app/test-runner after file-updates due to paranoia, and there was alot of loader-related tech-debt i should have deleted years earlier, but didn’t due to sentimental value.

the *only* valid use-case for hot-loading modified-modules is during bootstrap-phase (with minimal integration-worries about module-dependency issues), so you can insert instrumentation-code for test-coverage like this real-world example [1].

[1] bootstrap to load modified-modules with instrumentation-code for test-coverage
https://github.com/kaizhu256/node-istanbul-lite/blob/2018.4.25/lib.istanbul.js#L2765 <https://github.com/kaizhu256/node-istanbul-lite/blob/2018.4.25/lib.istanbul.js#L2765>

kai zhu
kaizhu256 at gmail.com



> On 21 Sep 2018, at 1:33 AM, Isiah Meadows <isiahmeadows at gmail.com> wrote:
> 
> 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
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180924/2bec9644/attachment.html>


More information about the es-discuss mailing list