fix(otlp-exporter-base): remove usage of require in esm/esnext builds#5746
fix(otlp-exporter-base): remove usage of require in esm/esnext builds#5746EmrysMyrddin wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
|
8289bcc to
00a06f5
Compare
|
Oh ok, It's my first time trying to POC around this code base ^^' I haven't looked at how tests are made, since I wasn't expecting having to update tests for this PR :-P So not quite sure to understand how this change does break the setup ^^' I will follow your PR then ! Do you want me to close this one ? |
|
Has anyone looked into using |
|
I'm not sure how much this would be compatible with web/non node runtimes |
|
|
||
| return utils; | ||
| // Lazy require to ensure that http/https is not required before instrumentations can wrap it. | ||
| return (this._loadingUtils = import('./http-transport-utils').then( |
There was a problem hiding this comment.
If dynamic import fails you may want to add catch logic to handle the resultant error.
There was a problem hiding this comment.
It was not handled before, so to maintain the same behavior, I don't catch any error.
The rejected promise will be handled by the caller of send function if it needs to be handled.
|
closing in favor of #5719 which is fixing this and have working unit tests :-) |
Which problem is this PR solving?
ESM and ESNEXT builds are broken, because they contain the usage of
requirefunction to dynamically import packages.Short description of the changes
This PR is replacing the
requirecall with animportone. The only problem of this is that it is now asynchronous.But this is not a problem since we can change the return type of the method (it is a private method), and the caller is already async.
The only difficulty is to make sure there is no parallel loading happening.
Type of change
How Has This Been Tested?
I've tested it on my local project which was bundling an ESM Node application with Rollup.
Checklist:
[ ] Unit tests have been addedNot relevant, this PR doesn't add anything[ ] Documentation has been updatedNot relevant, it is purely internal changes