Skip to content

Commit

Permalink
fix: use require for import in the middle
Browse files Browse the repository at this point in the history
Fixes an issue where bundlers (esbuild) fail to build because of es
module interop issues
  • Loading branch information
dyladan committed Mar 14, 2024
1 parent 3a426e8 commit 6ffda27
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
Hooked,
} from './RequireInTheMiddleSingleton';
import type { HookFn } from 'import-in-the-middle';
import * as ImportInTheMiddle from 'import-in-the-middle';
const ImportInTheMiddle = require('import-in-the-middle');
import { InstrumentationModuleDefinition } from '../../types';
import { diag } from '@opentelemetry/api';
import type { OnRequireFn } from 'require-in-the-middle';
Expand Down Expand Up @@ -268,7 +268,7 @@ export abstract class InstrumentationBase<T = any>

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

0 comments on commit 6ffda27

Please sign in to comment.