Closed
Description
What happened?
Warning output from esbuild
bundler.
▲ [WARNING] Constructing "ImportInTheMiddle" will crash at run-time because it's an import namespace object, not a constructor [call-import-namespace]
node_modules/@opentelemetry/instrumentation-mongoose/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:259:30:
259 │ ... var esmHook = new ImportInTheMiddle([module_2.name], { in...
╵ ~~~~~~~~~~~~~~~~~
Consider changing "ImportInTheMiddle" to a default import instead:
node_modules/@opentelemetry/instrumentation-mongoose/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:48:7:
48 │ import * as ImportInTheMiddle from 'import-in-the-middle';
│ ~~~~~~~~~~~~~~~~~~~~~~
╵ ImportInTheMiddle
6 of 16 warnings shown (disable the message limit with --log-limit=0)
...310dc1affb2720b6af2dd368949f880c1da144faa5a6860bc328c2/index.mjs 3.8mb ⚠️
⚡ Done in 144ms
From the code, I would have to agree with the warning that this will crash if used.
I don't understand how you could import like this:
It is not valid to import like this:
And then instantiate like this:
It will absolutely throw an exception.
For ESM, the instantiation would need to look like:
var esmHook = new ImportInTheMiddle.default.default( ... );
But there are lots of things I do not know, so would be interested to hear if this would actually work!