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);
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too