dwyl/decache

Type: module and other esm implications

tcodes0 opened this issue · 1 comments

This library is really useful. It's like a missing piece to my REPL setup that allows me to reload code on filesystem events. I recently moved my code to esm using node's new type: module field in package.json. I'm also using ts-node which has WIP support for esm code loading.

The issue is that in my setup with latest node and esm, decache apparently doesn't work. Would it help to provide a code sandbox demo? I realize it could very well be ts-node or another piece of the puzzle not working. 🤔

to clarify: I'm also using typescript lol. And instead of require I write import (kinda obvious but just want to make sure we're on the same page here)

Did some digging on this. I think we are missing a require.cache equivalent on esm.
Related: https://stackoverflow.com/questions/51498129/require-cache-equivalent-in-es-modules
Related: nodejs/help#2806

repro: https://github.com/Thomazella/esm-repl-reload-repro