Add --module node22
(or --module node20
) with support for require(esm)
#60534
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
🔍 Search Terms
TS1479 is "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic import call instead."
But
require(ESM)
is now supported -- under--experimental-require-module
in node 20.x and 22.x and by default in node 23.x -- providing that the module graph contains no top-level await. So TypeScript needs a way to disable TS1479 when a user can assert that this is the case.✅ Viability Checklist
⭐ Suggestion
"module": "nodenext"
should disable TS1479.📃 Motivating Example
Prototype blog post announcement:
💻 Use Cases
Interoperability between ESM and CJS.
TypeScript does not allow CJS to require(ESM), even when it is supported by node.
Have to avoid doing that.
The text was updated successfully, but these errors were encountered: