Open happyhunter7 opened 1 month ago
We experienced another use-case that might benefit from some way to invalidate loaded modules.
It's related to the Deno kernel for Jupyter and using local utilities in the cells:
// utils.ts
export function log() {
console.log('Hi!');
}
// 000-deno.ipynb
import { log } from '/app/workspace/utilts.ts';
log();
There's no way to reload the utils.ts
without restarting the whole kernel, that could be inconvenient for large-ish notebooks with lots of data.
Starting from this issue here https://github.com/denoland/deno/issues/25742 I understood that there is a need in a
dynamicUncachedImport
utilAfter long discussions in that issue, seems that it should be a Feature request and not a Issue since it works the same on all 3 platforms Node, Deno, Bun But it would be beneficial for Deno to have it firstly
What would do
dynamicUncachedImport
It will import the given module in a uncached manier, ES can do that if you add a
? query string
at the end of module name, but it uncache only first level of import not nested imports inside, which may lead to bugs and is just a partialluncache
solution, it uncache only first level import not it's children importsWhere this may be used
Having such a util, we basically can implement HMR in Deno, without reloading the running process, I know Deno has
--watch-hmr
but most of the times it just reloads the process, and is not a programaticall thing you can't really controll itHaving it, we may build tools that allows to install plugins at runtime, wordpress like tools allowing to install themes at runtime, do server side rendering at runtime with changed JSX files
Basically What PHP world can do)) and that's why 70% of web still runs on it) because you have tools like wordpress that are famous for these features and you can change everything practically at runtime even code))
Actually the import should be cached but once a new Dynamic import happens with exact same path/name it should get the new version not one from cache