You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing a solution for a similar problem to that described in #35, I identified that there are two small changes which could be made to this module that facilitate the use of alternate resolvers such as the one used in webpack.
This basically comes down to exposing the list of hooks as a global and storing the resolve.sync function reference as a class member.
The example webhook plugin provided in #35 (with some modernization for webpack 5) works OK if require-in-the-middle is part of the webpack bundle. However, when instrumentation is set up prior to the execution of the bundle (e.g. when using opentelemetry's lambda layer or really any other case where the node option --require is used), it does not because the require-in-the-middle hooks have already been initialized. Where this becomes especially problematic is when the module being hooked is part of the webpack bundle.
Providing a global list of registered hooks and a way to override the sync function addresses this situation and, when not in use, should not impact other uses of this library.
The text was updated successfully, but these errors were encountered:
justinedelson
added a commit
to justinedelson/require-in-the-middle
that referenced
this issue
Jan 18, 2024
While developing a solution for a similar problem to that described in #35, I identified that there are two small changes which could be made to this module that facilitate the use of alternate resolvers such as the one used in webpack.
This basically comes down to exposing the list of hooks as a global and storing the
resolve.sync
function reference as a class member.The example webhook plugin provided in #35 (with some modernization for webpack 5) works OK if require-in-the-middle is part of the webpack bundle. However, when instrumentation is set up prior to the execution of the bundle (e.g. when using opentelemetry's lambda layer or really any other case where the node option
--require
is used), it does not because the require-in-the-middle hooks have already been initialized. Where this becomes especially problematic is when the module being hooked is part of the webpack bundle.Providing a global list of registered hooks and a way to override the
sync
function addresses this situation and, when not in use, should not impact other uses of this library.The text was updated successfully, but these errors were encountered: