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

fix: use require for import in the middle #4546

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix: require import-in-the-middle in order to fix an issue with bundlers [#4546](https://github.com/open-telemetry/opentelemetry-js/pull/4546) @dyladan

### :books: (Refine Doc)

* docs(instrumentation): better docs for supportedVersions option [#4693](https://github.com/open-telemetry/opentelemetry-js/pull/4693) @blumamir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
Hooked,
} from './RequireInTheMiddleSingleton';
import type { HookFn } from 'import-in-the-middle';
import * as ImportInTheMiddle from 'import-in-the-middle';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ImportInTheMiddle = require('import-in-the-middle');
import {
InstrumentationConfig,
InstrumentationModuleDefinition,
Expand Down Expand Up @@ -309,12 +310,11 @@ export abstract class InstrumentationBase<
: this._requireInTheMiddleSingleton.register(module.name, onRequire);

this._hooks.push(hook);
const esmHook =
new (ImportInTheMiddle as unknown as typeof ImportInTheMiddle.default)(
[module.name],
{ internals: false },
<HookFn>hookFn
);
const esmHook = new ImportInTheMiddle(
[module.name],
{ internals: false },
<HookFn>hookFn
);
this._hooks.push(esmHook);
}
}
Expand Down