I am running some code containing ES modules (in .mjs files) in a docker container with node:12.10.0 and the --experimental-modules flag. I am able to import opentracing from 'opentracing'; and things work as expected.
The issue appears when testing the code :
I am using Jest and therefore need to transpile the code through babel-jest. The setup I have works well, except for opentracing. In that case, 'opentracing' ends up being undefined, and things like opentracing.Tags result in an error.
I'm not sure exactly what's going wrong, but it seems to be related to the default export handling :
If I comment out the Object.defineProperty(exports, "__esModule", { value: true }); line in lib/index.js of opentracing, things work well.
They work correctly too if I add a exports.default = exports; in that file.
Without touching the opentracing node_module, I was able to make things work in the test environment by calling import { Tags } from 'opentracing';, but that does not work in the production environment (i.e. no transpilation process).
Please let me know if I can provide additional information to dig into the issue.