Skip to content

[Bug]: Jest 30.4.0 breaks CJS→ESM interop for packages with __esModule: true but no .default (e.g. tslib) #16142

@cschramm

Description

@cschramm

Version

30.4.0

Steps to reproduce

  1. Have a project with "type": "module" and --experimental-vm-modules
  2. Depend (directly or transitively) on any package whose ESM build imports from tslib — e.g. @peculiar/asn1-schema, whose import export condition resolves to an ES2015 build containing import { __decorate } from "tslib"
  3. Run jest

The failure chain:

  1. Jest resolves import { __decorate } from "tslib" via the import.node export condition → tslib/modules/index.js
  2. modules/index.js does import tslib from '../tslib.js' (a default import of the CJS file)
  3. Jest 30.4.0 sees exports.__esModule === true on tslib.js and sets defaultExport = exports.default → undefined
  4. const { __extends, ... } = tslib throws TypeError

Expected behavior

Tests pass, as they did with Jest 30.2.0.

Actual behavior

  TypeError: Cannot destructure property '__extends' of 'tslib' as it is undefined.                                                     
                                                                                                                                        
    at node_modules/tslib/modules/index.js:3:5

Additional context

No response

Environment

System:
    OS: Linux 7.0 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon  780M Graphics
  Binaries:
    Node: 25.9.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.13.0 - /usr/bin/npm

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