Skip to content

[Bug]: Jest w/pnp - using a dep's index.js instead of index.mjs file #15726

@lesleydreyer

Description

@lesleydreyer

Version

30.0.4

Steps to reproduce

Create a yarn pnp + typescript + esm + jest project.

Minimal reproduction here https://codesandbox.io/p/devbox/jest30-xf5ktt and run yarn test

Expected behavior

If I temporarily patch mnemonist and add some console logs it seems like in jest v29 it used the index.mjs while in jest 30 it's using the index.js. I read the release notes and maybe I'm missing something, but seems like it should still be using the index.mjs file. I think it's coming from the pnp resolver.

Thanks!

Actual behavior

It gives "SyntaxError: The requested module 'mnemonist' does not provide an export named 'LRUMap'".

Environment

System:
    OS: macOS 13.6.7
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
  Binaries:
    Node: 22.15.1 - ~/.nvm/versions/node/v22.15.1/bin/node
    Yarn: 4.9.2 - ~/.nvm/versions/node/v18.19.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.15.1/bin/npm
npmPackages:
    jest: 30.0.4
    mnemonist: 0.40.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions