Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

require.cache equivalent in ES modules

ES Modules docs states:

require.cache is not used by import. It has a separate cache.

So where's this separate cache? Is it accessible after all?

I'm looking for invalidating module caching as it can be done in CommonJS modules (node.js require() cache - possible to invalidate?)

like image 638
Matías Fidemraizer Avatar asked Jul 24 '18 12:07

Matías Fidemraizer


1 Answers

I saw your thread on the nodeJS github and your answer is there: the cache is designed to be immutable. There's also a good suggestion to use Workers, with each instance having its own fresh imports. Short of that, if you need this behaviour (which doesn't exist for a reason), is there perhaps a better way to design your application to not need it?

EDIT: The issue on GH: https://github.com/nodejs/help/issues/1399

like image 178
Brandon Lee Detty Avatar answered Oct 16 '22 20:10

Brandon Lee Detty