-
Notifications
You must be signed in to change notification settings - Fork 813
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
@opentelemetry/instrumentation crashes when used with typescript esModuleInterop: true
#3701
Comments
The suggested fix would require us to enable es module interop, which would in turn require our downstream consumers to enable it which we want to avoid. The real fix here is to add a named export to require in the middle so it can be used from Typescript more easily. The maintainer of that module was on the SIG call and is going to look into this for us. |
I'll get a new release of require-in-the-middle out that does: module.exports.Hook = Hook My understanding from the call is that this will allow |
@matthias-pichler-warrify I need some help reproducing what you see. I'd like to understand it and confirm that the proposed change in 'require-in-the-middle' will help. I have an attempted repro here: https://github.com/trentm/repro-otel-js-issue-3701 |
Also *prefer* this form. This is because it is, apparently, easier to type for and use named exports with TypeScript and ESM, rather than "default exports". Refs: open-telemetry/opentelemetry-js#3701
Also *prefer* this form. This is because it is, apparently, easier to type for and use named exports with TypeScript and ESM, rather than "default exports". Refs: open-telemetry/opentelemetry-js#3701
Any estimation when this will be released? |
It will be part of 1.13.0/0.39.0, next week most likely. |
What happened?
Steps to Reproduce
Create a Node application in TypeScript setting
esModuleInterop: true
intsconfig.json
. Add otel instrumentations using the@opentelemetry/instrumentation
package. Transpile the application using esbuild (with target format CommonJS). Try to run the application.Expected Result
Since the final application is a CommonJS file (not ESM) it should run without crashing.
Actual Result
Build warnings are produced and the application crashes.
Additional Details
This StackOverflow answer suggests that the culprit is indeed
esModuleInterop: true
. It seems to me that all that is needed is the following change here:OpenTelemetry Setup Code
package.json
Relevant log output
The text was updated successfully, but these errors were encountered: