Improve support for custom require hooks #65
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of, thanks for adding source map support! I've been trying to use
nyc@4
with the project that lead to my code coverage article from last week. I got it working but had to make some changes. This is the first PR which covers the custom require hook implementation.The custom hook should decide which modules it wants to ignore. For example Babel lets you customize this beyond just
node_modules
using theonly
andignore
options.Custom hooks often store the hook they're replacing, and may call this hook when loading a module (e.g. if they decide to ignore that particular module). Hooks may also be removed, restoring the original hook. Libraries like proxyquire always fall back to the original hook but modify the module object.
The implementation was changed to:
Module.prototype._compile
It's getting late in the day in my timezone so I haven't had a chance to update the tests to cover this new behavior. The test suite in my own project passes though when run under
nyc
so that's encouraging.