doc: remove extensionless CJS exception for type:module#62176
Open
mcollina wants to merge 1 commit intonodejs:mainfrom
Open
doc: remove extensionless CJS exception for type:module#62176mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina wants to merge 1 commit intonodejs:mainfrom
Conversation
Remove the documented exception that extensionless files in type: "module" packages are recognized as CommonJS when included via require(). This exception conflicted with the ESM resolution specification which states that extensionless files within a package scope with an explicit type field follow the format of the type field. The behavior on main already matches the ESM spec since nodejs#61600, this change aligns the CJS documentation accordingly. Refs: nodejs#61600 Refs: nodejs#62083
Collaborator
|
Review requested:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The CJS documentation has included an exception since v16 (added in #41383) stating that extensionless files in
type: "module"packages are recognized as CommonJS when included viarequire(). This exception conflicts with the ESM resolution specification which states that extensionless files within a package scope with an explicittypefield follow the format of thetypefield.Since #61600, the behavior on
mainalready matches the ESM spec: extensionless files respect thetypefield. This change aligns the CJS documentation accordingly by removing the contradicting exception.For v25.x, #62083 restores the documented exception as a targeted fix to avoid breaking packages like yargs v17 that relied on the old behavior.
Refs: #61600
Refs: #62083
Refs: #61971