Skip to content
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

Allow sync function to be modified at runtime #80

Open
justinedelson opened this issue Jan 18, 2024 · 0 comments
Open

Allow sync function to be modified at runtime #80

justinedelson opened this issue Jan 18, 2024 · 0 comments

Comments

@justinedelson
Copy link

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.

justinedelson added a commit to justinedelson/require-in-the-middle that referenced this issue Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant