Add --module node20
with require(esm)
support
#60761
Open
+38,682
−1,040
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #60534
require(esm)
is currently unflagged in Node.js v22, but may be in v20 by the time this PR lands for 5.8. We’ll have a discussion about the flag name if it doesn’t happen by 5.8-beta.This PR does not currently attempt to error on
require
calls of async modules (those with top-levelawait
). We do not emit any special marker in declaration files indicating the presence of TLA, which is a prerequisite. My suspicion is that the sentiment will be that a static check for async modules in therequire
graph is not worth the pain of making a backward-incompatible declaration file change.The other change in this PR is that import assertions are now prohibited in
--module nodenext
, since Node.js v22+ does not parse them. Since there have been a lot of module target changes in fast succession, here’s the summary:5.6
target
moduleResolution
es2022
node16
esnext
nodenext
5.7.3
target
moduleResolution
es2022
node16
esnext
nodenext
type "json"
5.8
target
moduleResolution
es2022
node16
es2022
node16
type "json"
es2023
node16
type "json"
esnext
nodenext
type "json"