Skip to content

[Bug]: Jest 30.4.x drops named exports from CJS modules where module.exports is a function #16146

@paemuri

Description

@paemuri

Version

30.4.1

Steps to reproduce

  1. Have a project with "type": "module" and --experimental-vm-modules
  2. Depend on a package that sets module.exports to a function or class

One exemple is ioredis@v5.10.1. Just add a test file with the following:

import { Redis } from 'ioredis';

Expected behavior

import { Redis } from 'ioredis' should've been resolved correctly.

Actual behavior

SyntaxError: The requested module 'ioredis' does not provide an export named 'Redis'

    at EsmLoader.tryLoadGraphSync (node_modules/jest-runtime/build/index.js:725:18)

Additional context

It seems similar to #16144, but sufficiently different for me to open a new issue. If it's deemed as duplicate, please, let me know.

Reproduction: https://github.com/paemuri/jest-ioredis-repro

Environment

System:
  OS: macOS 26.4.1
  CPU: (10) arm64 Apple M1 Pro
Binaries:
  Node: 24.15.0
  npm: 11.14.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions