Due to v8 stack traces only going so many deep by default, modules deep enough in the dependency tree such that clear has been called >~8 times do not get cleared. This is because resolve/parentModule relies on the v8 stack trace.
It seems to me we don't need to resolve moduleId when calling it recursively from within clear, since children are absolute paths.
I've copied this module into our project and fixed as so:
const clear = (moduleId: string) => {
clearInternal(moduleId, true);
}
const clearInternal = (moduleId: string, doResolve: boolean) => {
if (typeof moduleId !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof moduleId}\``);
}
const filePath = doResolve ? resolve(moduleId) : moduleId;
...
for (const id of children) {
clearInternal(id, false);
}
Due to v8 stack traces only going so many deep by default, modules deep enough in the dependency tree such that clear has been called >~8 times do not get cleared. This is because resolve/parentModule relies on the v8 stack trace.
It seems to me we don't need to resolve moduleId when calling it recursively from within clear, since children are absolute paths.
I've copied this module into our project and fixed as so: