Skip to content

ESM mode: let TypeScript emit ESM codes always when using with Babel #2650

@herschel666

Description

@herschel666

🚀 Feature Proposal

From my point of view this is a regression, but I guess you had good reasons to bind the module type to the supportsStaticESM-option of Jest. That's why I'm proposing it as a feature: allow to have moduleKind be ESNext independent of Jest's supportsStaticESM-option.

Motivation

The custom Jest preset of the Node/React framework my team and I are maintaining relies on the fact, that the transpiled Typescript, ts-jest passes on to Babel, still contains ES Modules. Otherwise the custom Babel plugin that is part of the preset stops working.

So we rather need the useESM-option to override the supportsStaticESM-option. Then ESM can be enabled implicitly by providing the respective environment to Jest. Or explicitly by setting useESM to true. And vice versa, ESM could be disabled while the environment indicates the opposite to Jest — whoever might need this.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions