Skip to content

[Bug]: allow require(esm) #15651

@dynst

Description

@dynst

Version

29.7.0

Steps to reproduce

Have a Jest unit test use require() on a dependency with an "exports" field giving ESM

Expected behavior

When running Node.js 20.19, require(esm) should work.

https://nodejs.org/en/blog/release/v20.19.0

Actual behavior

if (this.unstable_shouldLoadAsEsm(modulePath)) {
// Node includes more info in the message
const error: NodeJS.ErrnoException = new Error(
`Must use import to load ES Module: ${modulePath}`,
);
error.code = 'ERR_REQUIRE_ESM';
throw error;
}

Additional context

It'd be great to get a patch release of 29.7.1 that uses the more relaxed behavior of node 20.x. Node.js 18 has been EOL since April 30.

Environment

All of them

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