-
Notifications
You must be signed in to change notification settings - Fork 953
Closed
Labels
bugSomething isn't workingSomething isn't workingpriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etcBugs which cause problems in end-user applications such as crashes, data inconsistencies, etc
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:
Line 28 in ca027b5
| import * as ImportInTheMiddle from 'import-in-the-middle'; |
And then instantiate like this:
Lines 308 to 313 in ca027b5
| const esmHook = | |
| new (ImportInTheMiddle as unknown as typeof ImportInTheMiddle.default)( | |
| [module.name], | |
| { internals: false }, | |
| <HookFn>hookFn | |
| ); |
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!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etcBugs which cause problems in end-user applications such as crashes, data inconsistencies, etc