Код: Выделить всё
mod.jsКод: Выделить всё
console.log('in mod.ts')
< /code>
testcase.jsconst require = createRequire(import.meta.url)
require('./mod.js')
const key = Object.keys(require.cache)[0]
delete require.cache[key]
require('./mod.js')
< /code>
There are ways to do this in a CJS project such as this answer, but I can't figure out how to do it in an ESM project.
I expected to see the console log printed twice, but it only prints once.
Is there a way to successfully uncache a module and reload its body in this test case?
Подробнее здесь: https://stackoverflow.com/questions/795 ... aterequire
Мобильная версия