standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

Cache not updating when package is updated #874

Open tpluscode opened 4 years ago

tpluscode commented 4 years ago

I am consuming packages which have a ESM-powered commonjs main module.

Problem is that when I update to a new version, the cache is not cleared and ESM stubbornly runs the cached code from the previously installed version.

Setting the no-cache environment variable or package.json options does not work. Only nuking the node_modules/esm/node_modules/.cache helps

Related to #805?

dionysiusmarquis commented 4 years ago

I think I ran into a simmilar problem. I needed to clear some earlier required modules to be able to freshly riquire them at runtime. As soon as esm is initialized I will always get an cached module. I tried:

process.env.ESM_DISABLE_CACHE = true
require = require('esm')(module, { cache: false, cjs: { cache: false }, force: true })

If I test it without esm or @babel/register everythings works as expected and I will be able to freshly require modules.