I need to reimport module integration-test/integration
upon every run as this module can have code dynamically changed in it at run time. I am using NodeJS with experimental modules in order to be able to run ES6 Javascript.
It seems require
enables you to delete modules after you require them with the following code delete require.cache[require.resolve('./integration-test/integration.js')]
. How do I replicate this with ES6 import?
//FIXME delete cached module here
import("./integration-test/integration").then((module) => {
console.log('Importing integration');
stub = module;
if (module) resolve();
else reject();
});
I do have a very inelegant solution to this in which I write a new file with a new name and then import that as a different module, however, this is far less than ideal and would like to avoid it if possible due to the memory leak issues.