diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 65d1819485c..0f6a5af5c37 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -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 diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index 6c2aa08281e..f7932a79a06 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -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, @@ -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 - ); + const esmHook = new ImportInTheMiddle( + [module.name], + { internals: false }, + hookFn + ); this._hooks.push(esmHook); } }