-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to also clear cache for children modules #4
Conversation
…ed module using { children: true } passed as 2nd argument
while (i--) { | ||
delete require.cache[require.cache[filePath].children[i].id]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it maybe be smart to run the children through clear()
, making it recursive, instead of deleting them directly. That way the children too would be run through the code on line 26-35 that deletes the children from their parents, preventing memory leaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I was just working on a recursive implementation before I notice your comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm, yes, it probably would have been easier to use clear()
and comparing root directory to make sure files are nested inside.
I'm ok with adding this option, but it needs to be documented and tested. |
I'm not sure how to write a test in
I'm working on a script to add to
|
Closing this in favor of #9. |
Add option to also delete cache for all child modules of the specified module using { children: true } passed as 2nd argument