Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was archived by the owner on May 23, 2023. It is now read-only.

Default import is not working in some contexts #132

@mlarcher

Description

@mlarcher

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions