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.
Since RITM upgrade to v8.0.0 in @opentelemetry/instrumentation, a fallback on the
resolvemodule was removed: nodejs/require-in-the-middle@67076ff#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L73This fallback seems not to have been intended to support bundled code, but as a side effect it did. When bundling code with webpack, webpack provides its own loader instead of the node.js native
require.resolve. When usingrequire.resolveinside code bundled with webpack, it can only resolve modules that are in the bundle. The above link to the old code highlights the check forrequire.resolve && require.resolve.pathsboth being truthy. This check would fail since therequire.resolve.pathsis undefined since it isn't needed in webpack's "stubbed"require.resolve, leading to theresolvemodule being used instead.So since this change was introduced, that is actually breaking instrumentation that needs to hook non-core modules through RITM.
This change externalizes the RITM dependency so it can make use of the actual node.js
require.resolvein the node.js runtime instead of the webpack loader.