denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.67k stars 5.25k forks source link

Proposal: Module Loader API #8327

Open kitsonk opened 3 years ago

kitsonk commented 3 years ago

With ES Modules, it is effectively impossible to do "hot module reloading" of the modules, as ES Module specification is fairly strict that once the module is resolve and its two pass instantiation is done, that is the end of the road for the module and cannot be replaced.

When you are mocking/testing/etc. though, it is potentially valuable to make changes to a module and "reload" it via dynamic import. In Node.js, they have solved this problem with an experimental loader API. For an example of how this gets integrated to provide a mechanism for module replacements of imports that are still modules, quibble provides ESM support. It basically creates a unique specifier for every time the module is requested to get around the challenge of ES modules being static once resolved.

This would also support solving things like #1739, which we have long wanted to do.

chrisabrams commented 1 year ago

@kitsonk did you ever come across a solution for readTextFile invalidation?

happyhunter7 commented 2 weeks ago

So any news on this)

Deno team consistently closes every new task opened and links to this And no action on this for 4 years

If you check above at least 10issues closed in favor to this and nothing is happening

cc @lucacasonato just pointing to a big problem, especially, a bug closed with no reason https://github.com/denoland/deno/issues/25742