Skip to content

[Bug]: ESM-CJS interoperability issue of getting incorrectly imported default module #16144

@jmuransky

Description

@jmuransky

Version

30.4.1

Steps to reproduce

Run jest with --experimental-vm-modules on codebase with strongly mixed esm and cjs dependencies.
Upon jest executing this line:
import thunk from 'redux-thunk'

(redux-thunk@2.4.2)

I am getting object like this:
{__esModule: true, default: ƒ}

Instead of default function.

Source of the issue was found within this MR (which created the regression for me): #16143 (comment)

Expected behavior

I expect thunk variable to contain default function (the same way as is executed in browser handled by webpack/craco), so that my test executes the same way as my browser does

Actual behavior

thunk is object

Additional context

No response

Environment

System:
    OS: Windows 11 10.0.22631
    CPU: (14) x64 Intel(R) Core(TM) Ultra 5 235U
  Binaries:
    Node: 24.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Users\myj\AppData\Roaming\npm\yarn.CMD
    npm: 11.12.1 - C:\Program Files\nodejs\npm.CMD

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