elastic / require-in-the-middle

Module to hook into the Node.js require function
MIT License
168 stars 26 forks source link

feat!: use `require.cache` for caching patched exports for non-core modules #63

Closed trentm closed 1 year ago

trentm commented 1 year ago

This allows a user to delete from require.cache to trigger a re-load of a module (and a re-run of the hook's onrequire) on next require().

This also removes the .cache field from the Hook object. It was never documented, but it wasn't prefixed with _ to hint at being private. As well, some tests used it, which might have given the impression it could be used externally. I'm calling this a semver-major change to give a heads up to users that might have been using it.

Fixes: #61 Obsoletes: #57

checklist

0x006EA1E5 commented 1 year ago

Any idea when this will be merged? :)

trentm commented 1 year ago

Any idea when this will be merged? :)

Soon. We discussed it in the OTel JS SIG today. Should be this week.